Example usage for java.sql DriverManager getConnection

List of usage examples for java.sql DriverManager getConnection

Introduction

In this page you can find the example usage for java.sql DriverManager getConnection.

Prototype

private static Connection getConnection(String url, java.util.Properties info, Class<?> caller)
            throws SQLException 

Source Link

Usage

From source file:Main.java

public static Connection getConnection() throws Exception {
    String driver = "oracle.jdbc.driver.OracleDriver";
    String url = "jdbc:oracle:thin:@localhost:1521:databaseName";
    String username = "name";
    String password = "password";
    Class.forName(driver); // load Oracle driver
    Connection conn = DriverManager.getConnection(url, username, password);
    return conn;//from  ww w  .  j  a  v  a2  s  . c om
}

From source file:SimpleProgramToAccessOracleDatabase.java

public static Connection getConnection() throws Exception {
    // load the Oracle JDBC Driver
    Class.forName("oracle.jdbc.driver.OracleDriver");
    // define database connection parameters
    return DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:database", "userName", "password");
}

From source file:TestAccessExcel.java

public static Connection getConnection() throws Exception {
    String driver = "sun.jdbc.odbc.JdbcOdbcDriver";
    String url = "jdbc:odbc:excelDB";
    String username = "username";
    String password = "pass";
    Class.forName(driver);//ww w .  ja v a 2  s . c o  m
    return DriverManager.getConnection(url, username, password);
}

From source file:DemoPreparedStatementSetBigDecimal.java

public static Connection getConnection() throws Exception {
    String driver = "oracle.jdbc.driver.OracleDriver";
    String url = "jdbc:oracle:thin:@localhost:1521:databaseName";
    String username = "name";
    String password = "password";
    Class.forName(driver);/*from  w w  w . jav a 2 s.co m*/
    Connection conn = DriverManager.getConnection(url, username, password);
    return conn;
}

From source file:Main.java

public static Connection getConnection() {
    Connection conn = null;//from  w  w  w .  j  a va 2 s . com
    getParam("oracle.properties");
    try {
        Class.forName(driver);
        conn = DriverManager.getConnection(url, dbUser, dbPwd);
    } catch (Exception e) {
        e.printStackTrace();
    }
    return conn;
}

From source file:Main.java

public static Connection getConnection() throws Exception {
    String driver = "org.gjt.mm.mysql.Driver";
    String url = "jdbc:mysql://localhost/octopus";
    String username = "root";
    String password = "root";
    Class.forName(driver);/*from ww w. j  a  va 2s  .  c o  m*/
    Connection conn = DriverManager.getConnection(url, username, password);
    return conn;
}

From source file:DemoScrollableResultSet_MySQL.java

public static Connection getConnection() throws Exception {
    String driver = "org.gjt.mm.mysql.Driver";
    String url = "jdbc:mysql://localhost/databaseName";
    String username = "root";
    String password = "root";
    Class.forName(driver);/*ww  w  .  j  a  v a  2 s .co m*/
    return DriverManager.getConnection(url, username, password);
}

From source file:InsertCustomType2_Oracle.java

public static Connection getConnection() throws Exception {
    String driver = "oracle.jdbc.driver.OracleDriver";
    String url = "jdbc:oracle:thin:@localhost:1521:databaseName";
    String username = "name";
    String password = "pass";
    Class.forName(driver); // load Oracle driver
    return DriverManager.getConnection(url, username, password);
}

From source file:TestConnectToMoreThanOneDatabase.java

public static Connection getOracleConnection() throws Exception {
    String driver = "oracle.jdbc.driver.OracleDriver";
    String url = "jdbc:oracle:thin:@localhost:1521:scorpian";
    String username = "userName";
    String password = "pass";
    Class.forName(driver); // load Oracle driver
    Connection conn = DriverManager.getConnection(url, username, password);
    return conn;// w w  w . j  a  va 2  s  .co m
}

From source file:Main.java

public static Connection getConnection(String dbURL, String user, String password)
        throws SQLException, ClassNotFoundException {
    Class.forName("com.mysql.jdbc.Driver");
    return DriverManager.getConnection(dbURL, user, password);
}