cliblc
cliblc
2016-05-26 12:13

sqlserver数据库连接编写的类运行出来报ConnectionID:1是为什么?求指导

5

package com.db;

import java.sql.*;
public class DBHelper {

String driverName="com.microsoft.sqlserver.jdbc.SQLServerDriver";
String dbRUL="jdbc:sqlserver://localhost:1433;DatabaseName=Clothes system";
String userName="sa";
String userPwd="123456";

public Connection getConn(){
Connection conn = null;
try{
Class.forName(driverName);
}
catch(Exception e){}
try{
conn=DriverManager.getConnection(dbRUL,userName,userPwd);
}
catch(SQLException ex){}
return conn;

}

public static void main(String[] args)
{
System.out.println(new DBHelper().getConn());

}

}

  • 点赞
  • 回答
  • 收藏
  • 复制链接分享

2条回答

为你推荐