Java JDBC Derby Connection getConnection()

Here you can find the source of getConnection()

Description

get Connection

License

Open Source License

Declaration

public static Connection getConnection() 

Method Source Code


//package com.java2s;
//License from project: Open Source License 

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;

public class Main {
    private static Connection connection = null;

    public static Connection getConnection() {
        if (connection != null) {
            return connection;
        } else {//from   w w  w  .j av a 2  s.c o m
            try {
                String host = "jdbc:derby://localhost:1527/RosterDB";
                String uName = "app";
                String uPass = "app";
                connection = DriverManager.getConnection(host, uName, uPass);
            } catch (SQLException err) {
                System.out.println(err.getMessage());
            }
            return connection;
        }
    }
}

Related

  1. createConnection(String userName, String password)
  2. createXATransactionView(Statement s)
  3. deleteTestData()
  4. existsInSessionTable(String id, boolean verbose)
  5. getConnection()
  6. getDatabaseConnection()
  7. getDefaultDerbyConnection()
  8. getDerbyConnection(String filename)
  9. getDerbyDatabaseProperty(Statement derbyStatementForQuerying, String propertyKey)