?? dbcon.java
字號:
// DBCon.java
import java.io.*;
import java.sql.*;
public class DBCon
{
private Connection con = null;
// constructor
public DBCon()
{
getConnection();
}
// get connection
public Connection getConnection()
{
if ( con == null )
{
try
{
Class.forName( "sun.jdbc.odbc.JdbcOdbcDriver" );
con = DriverManager.getConnection( "jdbc:odbc:student" );
}catch ( Exception ex ){
System.out.println( ex.toString() );
}
}
return this.con;
} // end of get connection
// close connection
public void close()
{
try
{
con.close();
con = null;
}
catch ( SQLException sex )
{
System.out.println( sex.toString() );
}
} // end of method close
// automaticly run the method when object are added into session
public void Close()
{
if ( con != null )
{
try
{
con.close();
con = null;
}catch ( SQLException sex ){
System.out.println( sex.toString() );
}
}
}
} // end of class DBCon
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -