Q
qdwitty
Unregistered / Unconfirmed
GUEST, unregistred user!
我用的是Resin2.1.9服务器,安装了SQL Server for JDBC Driver,为什么会出现如下的错误
提示,我已经将三个jar文件Copy到了lib目录下。
源码:
String driverstring="com.microsoft.jdbc.sqlserver.SQLServerDriver";
String urlstring= "jdbc:microsoft:sqlserver://127.0.0.1:1433;DatabaseName=pubs";
Class.forName(driverstring).newInstance();
Connection conn =DriverManager.getConnection(urlstring,"sa","54321");
Statement stmt=conn.createStatement();
String sql="select * from employee";
ResultSet rs=stmt.executeQuery(sql);
错误提示:
java.lang.ClassNotFoundException: com.microsoft.jdbc.sqlserver.SQLServerDriver
at com.caucho.util.DynamicClassLoader.loadClass(DynamicClassLoader.java:530)
at java.lang.ClassLoader.loadClass(ClassLoader.java:255)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:315)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:140)
at _sql__jsp._jspService(/sql.jsp:12)
at com.caucho.jsp.JavaPage.service(JavaPage.java:75)
at com.caucho.jsp.Page.subservice(Page.java:506)
at com.caucho.server.http.FilterChainPage.doFilter(FilterChainPage.java:182)
at com.caucho.server.http.Invocation.service(Invocation.java:315)
at com.caucho.server.http.CacheInvocation.service(CacheInvocation.java:135)
at com.caucho.server.http.HttpRequest.handleRequest(HttpRequest.java:246)
at com.caucho.server.http.HttpRequest.handleConnection(HttpRequest.java:163)
at com.caucho.server.TcpConnection.run(TcpConnection.java:139)
at java.lang.Thread.run(Thread.java:536)
提示,我已经将三个jar文件Copy到了lib目录下。
源码:
String driverstring="com.microsoft.jdbc.sqlserver.SQLServerDriver";
String urlstring= "jdbc:microsoft:sqlserver://127.0.0.1:1433;DatabaseName=pubs";
Class.forName(driverstring).newInstance();
Connection conn =DriverManager.getConnection(urlstring,"sa","54321");
Statement stmt=conn.createStatement();
String sql="select * from employee";
ResultSet rs=stmt.executeQuery(sql);
错误提示:
java.lang.ClassNotFoundException: com.microsoft.jdbc.sqlserver.SQLServerDriver
at com.caucho.util.DynamicClassLoader.loadClass(DynamicClassLoader.java:530)
at java.lang.ClassLoader.loadClass(ClassLoader.java:255)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:315)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:140)
at _sql__jsp._jspService(/sql.jsp:12)
at com.caucho.jsp.JavaPage.service(JavaPage.java:75)
at com.caucho.jsp.Page.subservice(Page.java:506)
at com.caucho.server.http.FilterChainPage.doFilter(FilterChainPage.java:182)
at com.caucho.server.http.Invocation.service(Invocation.java:315)
at com.caucho.server.http.CacheInvocation.service(CacheInvocation.java:135)
at com.caucho.server.http.HttpRequest.handleRequest(HttpRequest.java:246)
at com.caucho.server.http.HttpRequest.handleConnection(HttpRequest.java:163)
at com.caucho.server.TcpConnection.run(TcpConnection.java:139)
at java.lang.Thread.run(Thread.java:536)