【Java开源代码栏目提醒】:网学会员Java开源代码为您提供CommonaJdbc.java参考,解决您在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;
}
}
上一篇:
common.java
下一篇:
凉凉的清晨