import java
public class AccessDB {
String driver =
String url =
String user =
String pwd =
Connection conn;
Statement stmt;
ResultSet rs;
public MyDB() {
try {
Class
} catch (Exception e) {
System
}
}
//創建不可滾動的連接
public void connect() {
try {
conn = DriverManager
stmt = conn
} catch (Exception e) {
System
}
}
//創建可以滾動的連接
public void connect
try {
conn = DriverManager
stmt = conn
} catch (Exception e) {
System
}
}
//關閉連接
public void close() {
try {
if (stmt != null) {
stmt
}
if (conn != null) {
conn
}
} catch (Exception e) {
System
}
}
//查詢語句
public ResultSet executeQuery(String sql) {
try {
if (stmt == null) {
connect();
}
rs = stmt
} catch (Exception e) {
System
}
return rs;
}
}
From:http://tw.wingwit.com/Article/program/Java/JSP/201311/19541.html