📄 msssqlfather.java
字号:
/*
* MSSSQL.java
*
* Created on 2008年1月22日, 下午1:17
*
* To change this template, choose Tools | Template Manager
* and open the template in the editor.
*/
package javaapplication6;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import javax.swing.JOptionPane;
/**
*
* @author jianren
*/
public class MSSSQLFather {
/** Creates a new instance of MSSSQL */
protected final static String strurl =
"jdbc:odbc:driver={Microsoft Access Driver (*.mdb)};DBQ=date/MSSData.mdb";
protected final static String sql = "jdbc:odbc:MSSData";
protected final static String div = "sun.jdbc.odbc.JdbcOdbcDriver";
protected final static String sqlUser = "123";
protected final static String sqlPass = "123";
protected static Connection con = null;
protected static Statement sta = null;//SQL对象
protected static ResultSet re = null;//查询结果
MSSSQLFather() {
line( sql, sqlUser, sqlPass);
}
public static Statement getStatement(){
return sta;
}
public static boolean close(){
if( sta == null || re == null){
return false;
}
try {
sta.close();
} catch (SQLException ex) {
//*ex.printStackTrace();
return false;
}
try {
re.close();
} catch (SQLException ex) {
//ex.printStackTrace();
return false;
}
return true;
}
public boolean line( String sqlUrl, String User, String Pass) {
if( sqlUrl == null){
return false;
}
try {
Class.forName( div);
} catch (ClassNotFoundException ex) {
return false;
}
try {
con = null;
con = DriverManager.getConnection( sql, sqlUser, sqlPass);
} catch (SQLException ex) {
return false;
}
try {
sta = con.createStatement( /*ResultSet.TYPE_SCROLL_SENSITIVE,
ResultSet.CONCUR_UPDATABLE*/);
} catch (SQLException ex) {
return false;
}
return true;
}
//返回查询结果
public ResultSet see( String url){
if( url == null){
return null;
}
try {
re = sta.executeQuery( url);
} catch (SQLException ex) {
return null;
}
return re;
}
//更新,添加,删除
public boolean executeUpdate( String url){
if( url == null){
return false;
}
try {
sta.executeUpdate( url);
} catch (SQLException ex) {
return false;
}
return true;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -