文件名称:连接sql数据库的jdbc类
文件大小:2KB
文件格式:TXT
更新时间:2018-01-14 09:27:50
sql 数据库 jdbc jsp
public class JDBConnection { private final String url = "jdbc:jtds:sqlserver://192.168.100.91:1433/itzcgl"; private final String userName = "itzcgly"; private final String password = "itadmin#"; private Connection con = null; // 通过构造方法加载数据库驱动 static { try { Class.forName("net.sourceforge.jtds.jdbc.Driver").newInstance(); } catch (Exception ex) { System.out.println("数据库加载失败"); } } // 创建数据库连接 public boolean creatConnection() { try { con = DriverManager.getConnection(url, userName, password); con.setAutoCommit(true); } catch (SQLException e) { System.out.println(e.getMessage()); System.out.println("creatConnectionError!"); }