Here you can find the source of getMySQLConnection(Properties props)
public static Connection getMySQLConnection(Properties props) throws InstantiationException, IllegalAccessException, ClassNotFoundException, SQLException
//package com.java2s; /**//from w w w.j a v a2 s. com * Project: bee-engine * * File Created at 2012-9-11 * * Copyright 2012 dianping.com. * All rights reserved. * * This software is the confidential and proprietary information of * Dianping Company. ("Confidential Information"). You shall not * disclose such Confidential Information and shall use it only in * accordance with the terms of the license agreement you entered into * with dianping.com. */ import java.sql.Connection; import java.sql.DriverManager; import java.sql.SQLException; import java.util.Properties; public class Main { public static Connection getMySQLConnection(Properties props) throws InstantiationException, IllegalAccessException, ClassNotFoundException, SQLException { if (props == null) { props = new Properties(); } String url = props.getProperty("url") == null ? "jdbc:mysql://localhost:3306/" : props.getProperty("url"); String db = props.getProperty("db") == null ? "cdcol" : props.getProperty("db"); String driver = "com.mysql.jdbc.Driver"; if (props.getProperty("user") == null) { props.setProperty("user", "root"); } if (props.getProperty("password") == null) { props.setProperty("password", ""); } if (props.getProperty("useServerPrepStmts") == null) { props.setProperty("useServerPrepStmts", "true"); } if (props.getProperty("useUnicode") == null) { props.setProperty("useUnicode", "true"); } Class.forName(driver).newInstance(); DriverManager.setLoginTimeout(600); Connection conn = DriverManager.getConnection(url + db, props); return conn; } }