在做一个帐户管理练习项目,使用Jbuilder2006+Mysql5.0
最新版的connetor-j已经加载好,在Jbuilder及命令提示符下分别用自己写的小程序测试过,连接MYSQL都没问题,能顺利读写,在Jbuilder的databasepilot也能进入目标数据库.
我的项目里我建了一个类来管理连接
public class cardConnect {
private static cardConnect dbconn = new cardConnect();
public cardConnect() {
try{
Class.forName( "com.mysql.jdbc.Driver ");
}
catch(ClassNotFoundException ee){ }
}
public static Connection getconn() throws Exception{ String url= "jdbc:mysql://localhost:3306/credit_card ";
String username= "root ";
String password= " ";
return DriverManager.getConnection(url,username,password);
}
public static void close(ResultSet rs){
try{
rs.close();
}
catch(Exception ex){
}
}
public static void close(Statement stmt){
try{
stmt.close();
}
catch(Exception ex){
}
}
public static void close(Connection conn){
try{