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:TestAppletPolicy.java

public void init() {
    System.out.println(getParameter("otherparams"));
    try {//  ww w  .  j  a v a  2s .com
        System.out.println("init(): loading OracleDriver for applet created at " + created.toString());
        DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver());
        System.out.println("init(): getting connection");
        conn = DriverManager.getConnection("jdbc:oracle:thin:@dssnt01:1521:dssora01", "scott", "tiger");
    } catch (SQLException e) {
        System.err.println("init(): SQLException: " + e.getMessage());
    }
}

From source file:com.rplt.studioMusik.model.DatabaseConnection.java

public static Connection getmConnection() {
    String jdbcURL = null;/*from w ww  .j a  v  a2s .co m*/
    String username = null;
    String password = null;

    Connection conn = null;
    try {
        //            jdbcURL = "jdbc:oracle:thin:@localhost:1521:xe";
        //            username = "mhs125314109";
        //            password = "mhs125314109";
        //            Class.forName("oracle.jdbc.driver.OracleDriver");
        jdbcURL = "jdbc:mysql://localhost:3306/studiomusik";
        username = "mhs125314109";
        password = "mhs125314109";
        Class.forName("com.mysql.jdbc.Driver");
        conn = DriverManager.getConnection(jdbcURL, username, password);
    } catch (Exception ex) {
        ex.printStackTrace();
    }

    return conn;
}

From source file:com.neu.edu.DAO.DAO.java

public Connection getConnection() {
    Connection conn = null;/*from w ww  . j a va 2  s .com*/
    try {
        conn = DriverManager.getConnection(dburl, dbuser, dbpassword);

    } catch (SQLException ex) {
        Logger.getLogger(DAO.class.getName()).log(Level.SEVERE, null, ex);
    }
    return conn;
}

From source file:GetColumnPrivilegesOracle.java

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

From source file:com.me.DAO.DAO1.java

public Connection getConnection() {
    Connection conn = null;/*from   ww  w  .  ja  va2  s.  c  o  m*/
    try {
        conn = DriverManager.getConnection(dburl, dbuser, dbpassword);

    } catch (SQLException ex) {
        Logger.getLogger(DAO1.class.getName()).log(Level.SEVERE, null, ex);
    }
    return conn;
}

From source file:Main.java

private static Connection getHSQLConnection() throws Exception {
    Class.forName("org.hsqldb.jdbcDriver");
    String url = "jdbc:hsqldb:mem:data/tutorial";

    DriverManager.setLogWriter(new PrintWriter("yourFileName.log"));

    return DriverManager.getConnection(url, "sa", "");
}

From source file:geocodingsql.Main.java

public void establishConnection() {
    if (connection != null)
        return;/*from   w  w w .  j a va  2  s  .  co m*/
    String url = "jdbc:postgresql://50.177.247.244:5432/mydb";
    try {
        Class.forName("org.postgresql.Driver");

        connection = DriverManager.getConnection(url, username, password);

        if (connection != null) {
            System.out.println("Connecting to database...");
        }
    } catch (Exception e) {
        System.out.println("Problem when connecting to the database 1");
    }
}

From source file:Main.java

private static Connection getHSQLConnection() throws Exception {
    Class.forName("org.hsqldb.jdbcDriver");
    String url = "jdbc:hsqldb:mem:data/tutorial";

    return DriverManager.getConnection(url, "sa", "");
}

From source file:com.wipro.ats.bdre.clustermigration.SourceStageLoad.java

protected static Connection getHiveJDBCConnection(String dbName, String hiveConnection) throws SQLException {
    try {//from w  w w .  ja va2  s  . c om
        Class.forName(IMConstant.HIVE_DRIVER_NAME);
        Connection con = DriverManager.getConnection(hiveConnection + "/" + dbName, null, null);
        con.createStatement().execute("set hive.exec.dynamic.partition.mode=nonstrict");
        con.createStatement().execute("set hive.exec.dynamic.partition=true");
        con.createStatement().execute("set hive.exec.max.dynamic.partitions.pernode=1000");
        return con;
    } catch (ClassNotFoundException e) {
        throw new ETLException(e);
    } catch (SQLException e) {
        throw new ETLException(e);
    }
}

From source file:net.matthewauld.racetrack.server.WrSQL.java

public void connect() throws SQLException {
    con = DriverManager.getConnection(url, user, password);
}