日期:2014-05-17 浏览次数:20858 次
package dao;
import java.sql.Connection;
import java.sql.DriverManager;
public class MySQLHelper {
public MySQLHelper() {}
/**
*
* @return Connection
*/
public Connection getMySqlConnection() {
Connection conn = null;
String strDriverName="com.mysql.jdbc.Driver";//
String strUserName="xiaowei";//
String strUserPasswd="123456";
String strDbName="db_prj";//
String strUrl = "jdbc:MySQL://localhost/" + strDbName;//
try {
//
Class.forName(strDriverName).newInstance();
conn = DriverManager.getConnection(strUrl, strUserName, strUserPasswd);
} catch(Exception e) {
e.printStackTrace();
}
return conn;
}
}