java数据库连接中为什么总是出现这样的错误
java数据库连接中为什么总是出现这样的错误:SQLState:HY000Message:[Microsoft][SQLServer2000DriverforJDBC]U...
java数据库连接中为什么总是出现这样的错误:SQLState: HY000Message: [Microsoft][SQLServer 2000 Driver for JDBC]Unable to connect. Invalid URL.Vendor: 0
哪为高手能指点一下,源代码为:
import java.sql.*;
import java.sql.SQLException;
public class datds {
public static void main(String args[]){
String url="jdbc:microsoft:sqlserver:XIAOMING\\XIAOMING:1433;databasename=pubs";
try{
Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver"); Connection con=DriverManager.getConnection(url,"sa","121834");
System.out.print("herererererer");
System.out.println("connection succession");
Statement stmt=con.createStatement();
con.close();
}
catch(SQLException ex){
System.out.print("\n***SQLExceotion caught***\n");
while(ex!=null){
System.out.print("SQLState: "+ex.getSQLState());
System.out.print("Message: "+ex.getMessage());
System.out.print("Vendor: "+ex.getErrorCode());
ex=ex.getNextException();
System.out.println("");
}
}
catch(java.lang.Exception ex){
ex.printStackTrace();
}
}
}
url="jdbc:microsoft:sqlserver://localhost:1433;databasename=pubs"; 出现的错误也是一样
但我用VC的ADO 技术连接我的数据却完全没有任何的问题 展开
哪为高手能指点一下,源代码为:
import java.sql.*;
import java.sql.SQLException;
public class datds {
public static void main(String args[]){
String url="jdbc:microsoft:sqlserver:XIAOMING\\XIAOMING:1433;databasename=pubs";
try{
Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver"); Connection con=DriverManager.getConnection(url,"sa","121834");
System.out.print("herererererer");
System.out.println("connection succession");
Statement stmt=con.createStatement();
con.close();
}
catch(SQLException ex){
System.out.print("\n***SQLExceotion caught***\n");
while(ex!=null){
System.out.print("SQLState: "+ex.getSQLState());
System.out.print("Message: "+ex.getMessage());
System.out.print("Vendor: "+ex.getErrorCode());
ex=ex.getNextException();
System.out.println("");
}
}
catch(java.lang.Exception ex){
ex.printStackTrace();
}
}
}
url="jdbc:microsoft:sqlserver://localhost:1433;databasename=pubs"; 出现的错误也是一样
但我用VC的ADO 技术连接我的数据却完全没有任何的问题 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询