?? commonajdbc.java
字號:
package appstu.util;
import java.sql.Connection;
import java.sql.DriverManager;
public class CommonaJdbc {
public static Connection conection = null;
public CommonaJdbc(){
getCon();
}
private Connection getCon(){
try{
Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver");
conection = DriverManager.getConnection("jdbc:microsoft:sqlserver://127.0.0.1:1433;DatabaseName=DB_Student ","sa","");
// conection = DriverManager.getConnection("jdbc:microsoft:sqlserver://192.168.1.43:1433;DatabaseName=DB_Student ","sa","");
System.out.println("數據庫操作成功,祝賀你");
}catch(java.lang.ClassNotFoundException classnotfound){
classnotfound.printStackTrace();
}catch(java.sql.SQLException sql){
new appstu.view.JF_view_error(sql.getMessage());
sql.printStackTrace();
}
return conection;
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -