第一个包是page包,已经在page源码这里分享过了,现在来分享db包的源码
package duan.db;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.sql.Connection;
/**
* 连接mysql数据库
* @author duan
*/
public final class DbConn
{
public static Connection getconn()
{
Connection conn = null;
String user = "root";
String passwd = "******";
String url = "jdbc:mysql://127.0.0.1:3306/shop";
//已加载完驱动
try
{
Class.forName("com.mysql.jdbc.Driver");
conn = DriverManager.getConnection(url,user,passwd);
}catch (SQLException e)
{
e.printStackTrace();
}
catch (ClassNotFoundException e)
{
e.printStackTrace();
}
return conn;
}
}
package duan.db;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import