java课程设计----图书馆管理系统
}
}
package edu.njust.cs; import java.sql.*; import javax.swing.*; import java.util.*; import java.io.*; public class SqlUtil{
//读入配置文件
public static Properties loadProperty(String fileName){ }
Properties prop=new Properties(); try{ }
return prop;
FileInputStream in=new FileInputStream( prop.load(in); in.close();
System.getProperties().get("user.dir")+"/"+fileName);
}catch(IOException e){
e.printStackTrace();
JOptionPane.showMessageDialog(null, "配置文件丢失!\n建议重新安装程序",
"信息",
JOptionPane.ERROR_MESSAGE);
prop=null;
//建立和MS SQL SERVER的连接
public static Connection acquireConnection(
String host,String port,String dbName,String user, String pwd) throws ClassNotFoundException,SQLException{ Connection connection=null; try{
Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver"); String url ="jdbc:microsoft:sqlserver://"+
host+":"+port+";User="+user+";Password="+pwd;
connection= DriverManager.getConnection(url); connection.setCatalog(dbName);
e.printStackTrace(); throw e;
e.printStackTrace(); throw e;
}catch(ClassNotFoundException e){
}catch(SQLException e){