?? sqlhelper.java
字號:
package DataLayer;
import java.sql.*;
public class SqlHelper {
private String dbURL;
private String user;
private String password;
private Statement stmt;
public SqlHelper()
{
dbURL = "jdbc:odbc:ICQ";
user = "";
password = "";
}
SqlHelper(String Url,String User,String pwd)
{
this.dbURL = Url;
this.user = User;
this.password = pwd;
}
public Connection getConnection() {
try {
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
return DriverManager.getConnection(dbURL, user, password);
} catch (Exception e) {
System.out.print(e.toString());
}
return null;
}
public void setStatement(Connection con) {
try
{
stmt=con.createStatement();
}
catch(Exception e)
{
System.out.print(e.toString());
}
}
public ResultSet getQuery(String queryString) {
try
{
return stmt.executeQuery(queryString);
}catch (Exception e) {
System.out.print(e.toString());
}
return null;
}
public void getUpdate(String updateString) {
try
{
stmt.executeUpdate(updateString);
}catch (Exception e) {
System.out.print(e.toString());
}
}
public void closeStatement() {
try
{
stmt.close();
}catch (Exception e) {
System.out.print(e.toString());
}
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -