数据库连接错误: Unable to load class com.microsoft.jdbc.sqlserver.SQLServerDriver

andy_123 2003-08-25 04:39:40
Unable to load class com.microsoft.jdbc.sqlserver.SQLServerDriver
谁能告诉我如何配置?
...全文
1091 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
lhbf 2004-02-13
  • 打赏
  • 举报
回复
将jdbc驱动器包放在yourAppDir\WEB-INF\lib目录中。yourAppDir指你的web应用根目录。
lhbf 2004-02-13
  • 打赏
  • 举报
回复
微软自己提供的jdbc驱动只能用于mssqlserver2k,你的数据库版本是多少呢?
yanxibang 2004-02-13
  • 打赏
  • 举报
回复
一)各种数据库jdbc驱动程序
oracle驱动程序:http://otn.oracle.com/software/tech/java/sqlj_jdbc/content.html或者C:\oracle\ora81\jdbc\lib\classes12.zip(注意版本)
mysql驱动程序:http://www.mysql.com
sqlserver驱动程序:http://www.microsoft.com/china/sql/default.asp 下载setup.exe文件,再安装
二)驱动的安装
1)环境:WIN2K+j2sdk-1_4_1+tomcat连oracle817 将class12.zip文件改名为class12.jar,然后放到你的jsp目录的WEB-INF/lib下就可
连接程序代码如下:
<%@page contentType="text/html;charset=gb2312"%>
<%@page import="java.sql.*"%>
<%String sDBDrvier="oracle.jdbc.driver.OracleDriver";
String user="dq";
String pwd="dqdq";
String sConnStr="jdbc:oracle:thin:@192.168.0.49:1521:test"; //其中test是数据库的sid
Connection conn=null;
Statement stmt=null;
ResultSet rs=null;
String sqlStr="select * from t_user";
try{
Class.forName(sDBDrvier);
}
catch(ClassNotFoundException e)
{
System.out.println("数据库驱动类没找到");
}
try{
conn=DriverManager.getConnection(sConnStr,user,pwd);
stmt=conn.createStatement();
rs=stmt.executeQuery(sqlStr);
while(rs.next())
{
out.print(rs.getString("username"));
}
}
catch(SQLException ex)
{
System.out.print(ex.getMessage());
}
%>
报错原因:
The Network Adapter could not establish the connection 这可能是oracle的服务OracleServiceXB和OracleOraHome81TNSListener没有启动
Io 异常: Connection refused(DESCRIPTION=(TMP=)(VSNNUM=135294976)(ERR=12505)(ERROR_STACK=(ERROR=(CODE=12505)(EMFI=4)))) sid错误
No suitable driver 没有安装驱动程序
驱动程序版本不一致
2)环境:WIN2K+j2sdk-1_4_1+tomcat连sql server2000 将msbase.jar,mssqlserver.jar,msutil.jar放到你的jsp目录的WEB-INF/lib下就可
连接程序代码如下:
<%@page contentType="text/html;charset=gb2312"%>
<%@page import="java.sql.*"%>
<%String sDBDrvier="com.microsoft.jdbc.sqlserver.SQLServerDriver";
String user="sa";
String pwd="781213";
String sConnStr="jdbc:microsoft:sqlserver://localhost:1433;DatabaseName=test";
Connection conn=null;
Statement stmt=null;
ResultSet rs=null;
String sqlStr="select * from t_user";
try{
Class.forName(sDBDrvier).newInstance();
}
catch(ClassNotFoundException e)
{
System.out.println("数据库驱动类没找到");
}
try{
conn=DriverManager.getConnection(sConnStr,user,pwd);
stmt=conn.createStatement();
rs=stmt.executeQuery(sqlStr);
while(rs.next())
{
out.print(rs.getString("u_name"));
}
}
catch(SQLException ex)
{
System.out.print(ex.getMessage());
}
%>




连接access使用jdbc-odbc桥不配置odbc
try
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
}
catch(ClassNotFoundException ce)
{
System.out.println("SQLException:"+ce.getMessage());
}
try
{
String DbUrl = "jdbc:odbc:DRIVER={MICROSOFT ACCESS DRIVER (*.mdb)};DSN='';DBQ=E:\\ms.net\\sendmessage\\vbRs232\\mobilemessage.mdb";
String user = "";
String password = "";
Con=DriverManager.getConnection(DbUrl,user,password);
stmt = Con.createStatement();
}
catch(SQLException e)
{
System.out.println("SQLException"+e.getMessage());
}



























007james 2003-08-29
  • 打赏
  • 举报
回复
看完你就解决问题了

http://expert.csdn.net/Expert/topic/2199/2199403.xml?temp=.5593836
hsn1982 2003-08-25
  • 打赏
  • 举报
回复
说下你用的web server,mssql版本,操作系统啊

81,090

社区成员

发帖
与我相关
我的任务
社区描述
Java Web 开发
社区管理员
  • Web 开发社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧