Java JDBC MySQL Connection getConnection(String ip, String db, String user, String passWord)

Here you can find the source of getConnection(String ip, String db, String user, String passWord)

Description

get Connection

License

Apache License

Declaration

protected static Connection getConnection(String ip, String db, String user, String passWord) 

Method Source Code

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

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

public class Main {
    /**/*from w ww.j  av a 2  s.c  o m*/
     * @return
     */
    protected static Connection getConnection(String ip, String db, String user, String passWord) {
        Connection conn = null;
        try {
            Class.forName("com.mysql.jdbc.Driver");
            String url = "jdbc:mysql://" + ip + "/" + db;
            conn = (Connection) DriverManager.getConnection(url, user, passWord);
        } catch (Exception e) {
            e.printStackTrace();
        }
        return conn;
    }
}

Related

  1. getConnection(final String host, final int port, final String schema, final String user, final String password)
  2. getConnection(String connectionType)
  3. getConnection(String dbFile)
  4. getConnection(String dbUrl, String dbName, String userName, String password)
  5. getConnection(String ip, String dataBaseName, String password, String username)
  6. getConnetion(String url, String username, String password)
  7. getcount()
  8. getDBConn()
  9. getDbConnection()