谁给我解释下啊
public static final String driveName = "com.microsoft.sqlserver.jdbc.SQLServerDriver";
public static final String url = "jdbc:sqlserver://localhost:1433;DatabaseName=test";
public static final String user = "sasa";
public static final String password = "sasa";
public static void main(String[] args) {
String sql = "select * from dbo.user_table";
Connection con = null;
Statement st= null;
ResultSet rs= null;
System.out.println("加载驱动程序");
try {
Class.forName(driveName).newInstance();
System.out.println("驱动程序加载成功");
con = DriverManager.getConnection(url,user,password);
System.out.println("连接数据库");
st = con.createStatement();
rs = st.executeQuery(sql);
System.out.println("数据库连接成功");
while(rs.next()){
System.out.println("name:"+rs.getString("name")+" password:"+rs.getString("password"));
}
rs.close();
st.close();
con.close();
} catch (Throwable e) {
// TODO Auto-generated catch block
e.printStackTrace();
上面的代码执行到“驱动程序加载成功”在向下就不能执行了,请问是什么原因啊,还有DatebaseName 是什么意思啊 数据库名字吗?
------解决方案--------------------
------解决方案--------------------数据库有没有启动呀