myeclipse链接sqlserver2000
我的代码是这样packagecom.lw.tool;importjava.sql.*;publicclassJDBConnection{privatefinalStrin...
我的代码是这样
package com.lw.tool;
import java.sql.*;
public class JDBConnection {
private final String url="jdbc:microsoft:sqlserver://localhost:1433; databaseName=db_BlodMay";
private final String userName = "sa";
private final String password = "123";
private Connection con = null;
static {
try {
Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver").newInstance();
} catch (Exception ex) {
System.out.println("数据库加载失败");
}
}
然后报错如图: 展开
package com.lw.tool;
import java.sql.*;
public class JDBConnection {
private final String url="jdbc:microsoft:sqlserver://localhost:1433; databaseName=db_BlodMay";
private final String userName = "sa";
private final String password = "123";
private Connection con = null;
static {
try {
Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver").newInstance();
} catch (Exception ex) {
System.out.println("数据库加载失败");
}
}
然后报错如图: 展开
展开全部
package mybean;
import java.sql.*;
public class TestDB
{
public static void
main(String[] args)
{
String driverName =
"com.microsoft.jdbc.sqlserver.SQLServerDriver";
String dbURL =
"jdbc:microsoft:sqlserver://localhost:1433;DatabaseName=CarCtrl";
String
userName = "sa";
String userPwd =
"";
try
{
Class.forName(driverName);
DriverManager.getConnection(dbURL,
userName, userPwd);
System.out.println("Connection
Successful!");
}
catch (Exception
e)
{
e.printStackTrace();
}
}
}
import java.sql.*;
public class TestDB
{
public static void
main(String[] args)
{
String driverName =
"com.microsoft.jdbc.sqlserver.SQLServerDriver";
String dbURL =
"jdbc:microsoft:sqlserver://localhost:1433;DatabaseName=CarCtrl";
String
userName = "sa";
String userPwd =
"";
try
{
Class.forName(driverName);
DriverManager.getConnection(dbURL,
userName, userPwd);
System.out.println("Connection
Successful!");
}
catch (Exception
e)
{
e.printStackTrace();
}
}
}
本回答被提问者和网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询