当前位置: 技术问答>java相关
关于JB里操作SQL2000数据库的问题,郁闷2天了!
来源: 互联网 发布时间:2015-09-01
本文导语: 我下载了SQL2000的JDBC驱动程序,在JB7里配置后,可以连接SQL2000。 在SQL2000里建立了一个“test”数据库,一个“name”表。其中只有一个"name"字段,编了一段代码:试图访问该字段中的内容: 您的第一个字段内容为...
我下载了SQL2000的JDBC驱动程序,在JB7里配置后,可以连接SQL2000。
在SQL2000里建立了一个“test”数据库,一个“name”表。其中只有一个"name"字段,编了一段代码:试图访问该字段中的内容:
您的第一个字段内容为:
提示错误:
Error: 500 Location: /jspwebapp/test.jspInternal Servlet Error:javax.servlet.ServletException: com.microsoft.jdbc.sqlserver.SQLServerDriver
at org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:460)
at test_6._jspService(test_6.java:94)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:119)
at javax.servlet.http.HttpServlet.service(HttpServlet.java)
at org.apache.tomcat.facade.ServletHandler.doService(ServletHandler.java:574)
at org.apache.tomcat.core.Handler.invoke(Handler.java:322)
at org.apache.tomcat.core.Handler.service(Handler.java:235)
at org.apache.tomcat.facade.ServletHandler.service(ServletHandler.java:485)
at org.apache.tomcat.core.ContextManager.internalService(ContextManager.java:917)
at org.apache.tomcat.core.ContextManager.service(ContextManager.java:833)
at org.apache.tomcat.modules.server.Http10Interceptor.processConnection(Http10Interceptor.java:176)
at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:494)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:516)
at java.lang.Thread.run(Thread.java:484)
Root cause:
java.lang.ClassNotFoundException: com.microsoft.jdbc.sqlserver.SQLServerDriver
at org.apache.tomcat.util.depend.DependClassLoader.loadClassInternal1(DependClassLoader.java:186)
at org.apache.tomcat.util.depend.DependClassLoader12$1.run(DependClassLoader12.java:92)
at java.security.AccessController.doPrivileged(Native Method)
at org.apache.tomcat.util.depend.DependClassLoader12.loadClass(DependClassLoader12.java:90)
at java.lang.ClassLoader.loadClass(ClassLoader.java:253)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:313)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:120)
at test_6._jspService(test_6.java:58)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:119)
at javax.servlet.http.HttpServlet.service(HttpServlet.java)
at org.apache.tomcat.facade.ServletHandler.doService(ServletHandler.java:574)
at org.apache.tomcat.core.Handler.invoke(Handler.java:322)
at org.apache.tomcat.core.Handler.service(Handler.java:235)
at org.apache.tomcat.facade.ServletHandler.service(ServletHandler.java:485)
at org.apache.tomcat.core.ContextManager.internalService(ContextManager.java:917)
at org.apache.tomcat.core.ContextManager.service(ContextManager.java:833)
at org.apache.tomcat.modules.server.Http10Interceptor.processConnection(Http10Interceptor.java:176)
at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:494)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:516)
at java.lang.Thread.run(Thread.java:484)
请大家帮帮忙?
在SQL2000里建立了一个“test”数据库,一个“name”表。其中只有一个"name"字段,编了一段代码:试图访问该字段中的内容:
您的第一个字段内容为:
提示错误:
Error: 500 Location: /jspwebapp/test.jspInternal Servlet Error:javax.servlet.ServletException: com.microsoft.jdbc.sqlserver.SQLServerDriver
at org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:460)
at test_6._jspService(test_6.java:94)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:119)
at javax.servlet.http.HttpServlet.service(HttpServlet.java)
at org.apache.tomcat.facade.ServletHandler.doService(ServletHandler.java:574)
at org.apache.tomcat.core.Handler.invoke(Handler.java:322)
at org.apache.tomcat.core.Handler.service(Handler.java:235)
at org.apache.tomcat.facade.ServletHandler.service(ServletHandler.java:485)
at org.apache.tomcat.core.ContextManager.internalService(ContextManager.java:917)
at org.apache.tomcat.core.ContextManager.service(ContextManager.java:833)
at org.apache.tomcat.modules.server.Http10Interceptor.processConnection(Http10Interceptor.java:176)
at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:494)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:516)
at java.lang.Thread.run(Thread.java:484)
Root cause:
java.lang.ClassNotFoundException: com.microsoft.jdbc.sqlserver.SQLServerDriver
at org.apache.tomcat.util.depend.DependClassLoader.loadClassInternal1(DependClassLoader.java:186)
at org.apache.tomcat.util.depend.DependClassLoader12$1.run(DependClassLoader12.java:92)
at java.security.AccessController.doPrivileged(Native Method)
at org.apache.tomcat.util.depend.DependClassLoader12.loadClass(DependClassLoader12.java:90)
at java.lang.ClassLoader.loadClass(ClassLoader.java:253)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:313)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:120)
at test_6._jspService(test_6.java:58)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:119)
at javax.servlet.http.HttpServlet.service(HttpServlet.java)
at org.apache.tomcat.facade.ServletHandler.doService(ServletHandler.java:574)
at org.apache.tomcat.core.Handler.invoke(Handler.java:322)
at org.apache.tomcat.core.Handler.service(Handler.java:235)
at org.apache.tomcat.facade.ServletHandler.service(ServletHandler.java:485)
at org.apache.tomcat.core.ContextManager.internalService(ContextManager.java:917)
at org.apache.tomcat.core.ContextManager.service(ContextManager.java:833)
at org.apache.tomcat.modules.server.Http10Interceptor.processConnection(Http10Interceptor.java:176)
at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:494)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:516)
at java.lang.Thread.run(Thread.java:484)
请大家帮帮忙?
|
JBuilder连接数据库的jdbc驱动设置:
1.在tools->configre libraries->new->键入name->add->选择驱动文件。不妨设置在User Home下面
2.tools->enterprise setup->database Drier->add->选择刚才新建的
将你的jsp代码改动为如下再执行看看jb的错误提示输出:
您的第一个字段内容为:
1.在tools->configre libraries->new->键入name->add->选择驱动文件。不妨设置在User Home下面
2.tools->enterprise setup->database Drier->add->选择刚才新建的
将你的jsp代码改动为如下再执行看看jb的错误提示输出:
您的第一个字段内容为:
|
您的第一个字段内容为:
try {}块中并使用catch()来捕捉
Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver").newInstance的异常,newInstance()不要去掉。
然后看看输出的是什么异常,你就知道为什么了。
try {}块中并使用catch()来捕捉
Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver").newInstance的异常,newInstance()不要去掉。
然后看看输出的是什么异常,你就知道为什么了。