Here you can find the source of getJdbcConnection(String host, int port, String name, String user, String password)
public static Connection getJdbcConnection(String host, int port, String name, String user, String password)
//package com.java2s; //License from project: Apache License import java.sql.Connection; import java.sql.DriverManager; import java.sql.SQLException; import java.util.Properties; public class Main { public static Connection getJdbcConnection(String host, int port, String name, String user, String password) { Connection conn = null;/*from w ww. j a va 2 s . co m*/ Properties connectionProps = new Properties(); connectionProps.put("user", user); connectionProps.put("password", password); try { conn = DriverManager.getConnection( "jdbc:mysql://" + host + ":" + port + "/" + name + "?useUnicode=yes&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull", connectionProps); } catch (SQLException e) { throw new RuntimeException(e); } return conn; } }