String url = "jdbc:microsoft:sqlserver://localhost:1433;DatabaseName=product";
String username = "sa";
String password = "";
//定义驱动程序
String DBDRIVER="com.microsoft.jdbc.sqlserver.SQLServerDriver";
try
{
Class.forName(DBDRIVER);
}
catch(ClassNotFoundException ex)
{
ex.printStackTrace(System.err);
}
//获得连接
Connection conn=DriverManager.getConnection(url, username, password);
我的程序如上,可是最后一句,在eclipse中提示出错,说unhandle the type exception
请问是怎么回事?
谢谢
String username = "sa";
String password = "";
//定义驱动程序
String DBDRIVER="com.microsoft.jdbc.sqlserver.SQLServerDriver";
try
{
Class.forName(DBDRIVER);
}
catch(ClassNotFoundException ex)
{
ex.printStackTrace(System.err);
}
//获得连接
Connection conn=DriverManager.getConnection(url, username, password);
我的程序如上,可是最后一句,在eclipse中提示出错,说unhandle the type exception
请问是怎么回事?
谢谢
改下:
String url = "jdbc:microsoft:sqlserver://localhost:1433;DatabaseName=product";
String username = "sa";
String password = "";
//定义驱动程序
String DBDRIVER="com.microsoft.jdbc.sqlserver.SQLServerDriver";
try
{
Class.forName(DBDRIVER);
Connection conn=DriverManager.getConnection(url, username, password);
}
catch(ClassNotFoundException ex)
{
ex.printStackTrace(System.err);
}
catch(SQLException e){
e.printStackTrace();
}