文档介绍:源代码:
连接数据库的代码:
.;
import ;
import ;
import ;
import ;
import ;
public class ess {
final static private String strDriver="";
final static private String url="jdbc:mysql://localhost:3306/xjgl?userUnicode=true&characterEncoding=gb2312";
final static private String user="root";
final static private String password="admin";
private static ess db = null;
private Connection con;
private Statement stmt;
private ResultSet rst;
private ess(){
try {
(strDriver);
con=(url, user, password);
stmt=();
} catch (ClassNotFoundException e) {
// TODO Auto-generated catch block
();
} catch (SQLException e) {
// TODO Auto-generated catch block
();
}
}
public static ess ess(){
if(db==null){
db= new ess();
}
return db;
}
public Connection getConnection(){
return con;
}
public ResultSet query(String sql){
try {
rst=(sql);
} catch (SQLException e) {
// TODO Auto-generated catch block
();
}
return rst;
}
public int update(String sql){
int flag=0;
try {
flag=(sql);
} catch (SQLException e) {
// TODO Auto-generated catch block