📄 dbbridge.java
字号:
/**
* Created by IntelliJ IDEA.
* User: Administrator
* Date: Jul 18, 2003
* Time: 3:47:17 PM
* To change this template use Options | File Templates.
*/
package DBConnection;
import java.sql.*;
public class DBBridge {
private ConnPool connPool = null ;
private Connection conn = null;
private Statement stmt = null;
public DBBridge(){
try{
setConnectionSwitch("on");
}catch(Exception ex){
ex.printStackTrace();
}
}
public void closeDB() throws SQLException {
if( connPool!=null ) {
connPool.returnConnection() ;
connPool=null ;
}else{
System.err.println("The Connection has not been established !");
}
stmt=null ;
conn=null ;
}
public void openDB() throws SQLException {
connPool=ConnPool.getInstance() ;
conn=connPool.getConnection() ;
//stmt=conn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDATABLE);
stmt=conn.createStatement(java.sql.ResultSet.TYPE_SCROLL_INSENSITIVE,java.sql.ResultSet.CONCUR_READ_ONLY);
}
public void setConnectionSwitch( String on_off ) {
try {
if( on_off.equalsIgnoreCase( "ON" ) )
openDB() ;
else if( on_off.equalsIgnoreCase( "OFF" ) )
closeDB() ;
}
catch( SQLException ex ) {
ex.printStackTrace();
}
}
public Statement getStmt() {
return stmt;
}
public static void main(String args[]){
}
}
/*
public boolean openConnector(){
if (conn != null)
return true;
try{
Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver").newInstance();
String url="jdbc:microsoft:sqlserver://162.105.203.35:1433;DatabaseName=BBS";
String user="sa";
String password="bbs";
conn= DriverManager.getConnection(url,user,password);
stmt=conn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDATABLE);
}catch(Exception ex){
ex.printStackTrace();
return false;
}
return true;
}
public void closeConnector(){
try{
stmt.close();
conn.close();
}catch(Exception ex){
ex.printStackTrace();
}
}
*/
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -