X
xiaoboliu
Unregistered / Unconfirmed
GUEST, unregistred user!
SimpleDBConnect.java(from 1292.net)修正版
liuxiaobo 2001-09-26
/**
* Title: SimpleDBConnect.java
* Copyright: Copyright (c) 2001
* @author liuxiaobo
* @author xiaoboliu@cmmail.com
* @version 1.1
*/
package justforum.database;
import java.sql.*;
public class SimpleDBConnect {
private String driver="org.gjt.mm.mysql.Driver";
private String connectString="jdbc:mysql://localhost/forum";
private String user="root";
private String password="";
private Connection conn = null;
public void setParam(String driver,String connectString,String user,String password) {
this.driver=driver;
this.connectString=connectString;
this.user=user;
this.password=password;
}
public Connection getConnection() throws ClassNotFoundException,SQLException {
Class.forName(driver);
conn = DriverManager.getConnection(connectString,user,password);
return conn;
}
public void close() throws Exception {
conn.close();
conn = null;
}
}
liuxiaobo 2001-09-26
/**
* Title: SimpleDBConnect.java
* Copyright: Copyright (c) 2001
* @author liuxiaobo
* @author xiaoboliu@cmmail.com
* @version 1.1
*/
package justforum.database;
import java.sql.*;
public class SimpleDBConnect {
private String driver="org.gjt.mm.mysql.Driver";
private String connectString="jdbc:mysql://localhost/forum";
private String user="root";
private String password="";
private Connection conn = null;
public void setParam(String driver,String connectString,String user,String password) {
this.driver=driver;
this.connectString=connectString;
this.user=user;
this.password=password;
}
public Connection getConnection() throws ClassNotFoundException,SQLException {
Class.forName(driver);
conn = DriverManager.getConnection(connectString,user,password);
return conn;
}
public void close() throws Exception {
conn.close();
conn = null;
}
}