/*简便的JDBC工具
*非常好用
*/
import java.sql.Connection;
import java.sql.DriverManager;
public class DBCPUtils {
private static Connection conn;
public static Connection getConnection() throws Exception{
if(conn==null){
//初始化语句
Class.forName("com.mysql.jdbc.Driver");
conn=DriverManager.getConnection("jdbc:mysql://127.0.0.1:3306/gjp",
"root", "123");
}
return conn;
}
}
|
|