Here you can find the source of getMysqlCon(String ip, String port, String dbname, String username, String password)
public static Connection getMysqlCon(String ip, String port, String dbname, String username, String password)
//package com.java2s; //License from project: Open Source License import java.sql.Connection; import java.sql.DriverManager; import java.sql.SQLException; public class Main { public static Connection getMysqlCon(String ip, String port, String dbname, String username, String password) { Connection conn = null;//from w w w.j a v a 2s. c o m try { String url = "jdbc:mysql://" + ip + ":" + port + "/" + dbname; Class.forName("com.mysql.jdbc.Driver"); conn = DriverManager.getConnection(url, username, password); } catch (ClassNotFoundException e) { e.printStackTrace(); } catch (SQLException e) { e.printStackTrace(); } return conn; } }