Java JDBC MySQL Connection getConnetion(String url, String username, String password)

Here you can find the source of getConnetion(String url, String username, String password)

Description

get Connetion

License

Apache License

Declaration

public static Connection getConnetion(String url, String username, String password) 

Method Source Code


//package com.java2s;
//License from project: Apache License 

import java.sql.*;

public class Main {

    public static Connection getConnetion(String url, String username, String password) {
        final String driverName = "com.mysql.jdbc.Driver";
        Connection connection = null;
        try {//from w  ww.java 2s . c  o  m
            Class.forName(driverName);
            connection = DriverManager.getConnection(url, username, password);
        } catch (ClassNotFoundException e) {
            e.printStackTrace();
        } catch (SQLException e) {
            e.printStackTrace();
        }
        return connection;
    }
}

Related

  1. getConnection(String connectionType)
  2. getConnection(String dbFile)
  3. getConnection(String dbUrl, String dbName, String userName, String password)
  4. getConnection(String ip, String dataBaseName, String password, String username)
  5. getConnection(String ip, String db, String user, String passWord)
  6. getcount()
  7. getDBConn()
  8. getDbConnection()
  9. getDBConnection()