此处将为大家介绍关于无法为连接URL'null'创建类''的JDBC驱动程序:Tomcat&SQLServerJDBC驱动程序的详细内容,并且为您解答有关无法创建链接服务器null的oledb访问接口
此处将为大家介绍关于无法为连接URL'null'创建类''的JDBC驱动程序:Tomcat&SQL Server JDBC驱动程序的详细内容,并且为您解答有关无法创建链接服务器null的ole db访问接口的相关问题,此外,我们还将为您介绍关于Java JDBC - 如何使用JDBC驱动程序通过代理连接到MySQL、java – BIRT JDBCException“无法加载JDBC驱动程序类:com.mysql.jdbc.Driver”从2.6升级到3.7、java – 在Tomcat环境下无法获取MySQL的JDBC驱动程序、java – 我无法加载MySQL的JDBC驱动程序的有用信息。
本文目录一览:- 无法为连接URL'null'创建类''的JDBC驱动程序:Tomcat&SQL Server JDBC驱动程序(无法创建链接服务器null的ole db访问接口)
- Java JDBC - 如何使用JDBC驱动程序通过代理连接到MySQL
- java – BIRT JDBCException“无法加载JDBC驱动程序类:com.mysql.jdbc.Driver”从2.6升级到3.7
- java – 在Tomcat环境下无法获取MySQL的JDBC驱动程序
- java – 我无法加载MySQL的JDBC驱动程序
无法为连接URL'null'创建类''的JDBC驱动程序:Tomcat&SQL Server JDBC驱动程序(无法创建链接服务器null的ole db访问接口)
我已经尝试了几乎所有可以找到的一切,如果有人能够帮助我,我将永远感激不已(在我的时间里,我有更多的空闲时间)。
基本上,我在Tomcat
7.0中有一个错误(都是在Eclipse中运行并通过startup.bat运行时),该错误表示一旦动态Web应用程序开始访问数据,就会出现此错误:
Cannot create JDBC driver of class '''' for connect URL ''null''java.lang.NullPointerExceptionat sun.jdbc.odbc.JdbcOdbcDriver.getProtocol(JdbcOdbcDriver.java:507)at sun.jdbc.odbc.JdbcOdbcDriver.knownURL(JdbcOdbcDriver.java:476)at sun.jdbc.odbc.JdbcOdbcDriver.acceptsURL(JdbcOdbcDriver.java:307)
我的tomcat \ lib目录中有sqljdbc4.jar文件。我也尝试过将它放在我的WEB-INF / lib甚至JDK
lib目录中。我认为sqljdbc.jar不起作用,因为它是为比我的更老的JDK / JRE安装而设计的。
我听说context.xml和web.xml文件对于使其正常工作至关重要。
web.xml代码段:
<resource-ref><description>LBI DB Connection</description><res-ref-name>jdbc/LBIDB</res-ref-name><res-type>javax.sql.DataSource</res-type><res-auth>Container</res-auth><res-sharing-scope>Shareable</res-sharing-scope></resource-ref><resource-ref><description>OR DB Connection</description><res-ref-name>jdbc/ORDB</res-ref-name><res-type>javax.sql.DataSource</res-type><res-auth>Container</res-auth><res-sharing-scope>Shareable</res-sharing-scope></resource-ref>
context.xml
<Context><!-- Default set of monitored resources --><WatchedResource>WEB-INF/web.xml</WatchedResource><Resource name="jdbc/LBIDB" auth="Container"type="javax.sql.DataSource" username="***" password="***" driverClassName="com.microsoft.sqlserver.jdbc.SQLServerDriver" url="jdbc:sqlserver:localhost;DatabaseName=YYBackOffice;SelectMethod=cursor;"maxActive="8" maxIdle="4"/><Resource name="jdbc/ORDB" auth="Container"type="javax.sql.DataSource" username="***" password="***" driverClassName="com.microsoft.sqlserver.jdbc.SQLServerDriver" url="jdbc:sqlserver:localhost;DatabaseName=XXBackOffice;SelectMethod=cursor;"maxActive="8" maxIdle="4"/>
最终,“上下文”选项卡确实有一个关闭选项卡。
请帮忙!如果您需要更多信息,请告诉我。另外,我不确定应该修改哪个context.xml,在Tomcat目录中有2个,在/
conf文件夹中有1个,在webapps / appname / META-INF文件夹中有1个。抱歉,如果听起来我有点菜鸟,那是因为我在!
另外,我已经看到了context.xml的url =“
…”部分的许多不同示例,其中一些包括端口号。我已经在线尝试了一些方法,但是似乎没有任何效果(在线完全无济于事是我的确切数据环境,而且我认为此应用程序在给定的时间查询两个不同的DB很有挑战性)。
有什么想法吗?
答案1
小编典典在
context.xml
你的web应用程序的META-INF
文件夹将优先于一个在/ conf目录,这是真的只是一个普通的默认值。开源JTDS SQL Server驱动程序比Microsoft更好。除非有最重要的原因,否则请改用它。将其放置在tomcat / lib文件夹中的唯一原因是,如果在server.xml中声明数据库的GlobalNamingResource,否则可以将其放置在应用程序的/ lib文件夹中。
JTDS的JDBC URL为:
jdbc:jtds:sqlserver://hostname/databasename
JTDS的连接驱动程序类为:
net.sourceforge.jtds.jdbc.Driver
Java JDBC - 如何使用JDBC驱动程序通过代理连接到MySQL
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.Statement;
import java.util.Properties;
public class Main {
public static void main(String[] args) throws Exception{
Class.forName("com.mysql.jdbc.Driver");
Connection conn = null;
Properties info = new Properties();
// info.put("proxy_type", "4"); // SSL Tunneling
info.put("proxy_host", "[proxy host]");
info.put("proxy_port", "[proxy port]");
info.put("proxy_user", "[proxy user]");
info.put("proxy_password", "[proxy password]");
info.put("user", "[db user]");
info.put("password", "[db pass word]");
conn = DriverManager.getConnection("jdbc:mysql://[db host]/", info);
Statement stmt = conn.createStatement();
ResultSet rs = stmt.executeQuery("Select NOW()");
rs.next();
System.out.println("Data- " + rs.getString(1));
rs.close();
stmt.close();
conn.close();
}
}
java – BIRT JDBCException“无法加载JDBC驱动程序类:com.mysql.jdbc.Driver”从2.6升级到3.7
exception.error ( 1 time(s) ) detail : org.eclipse.birt.report.engine.api.EngineException: An exception occurred during processing. Please see the following message for details: Cannot open the connection for the driver: org.eclipse.birt.report.data.oda.jdbc. org.eclipse.birt.report.data.oda.jdbc.JDBCException: Cannot load JDBC Driver class: com.MysqL.jdbc.Driver. (Element ID:1351) at org.eclipse.birt.report.engine.executor.ExecutionContext.addException(ExecutionContext.java:1237) at org.eclipse.birt.report.engine.executor.ExecutionContext.addException(ExecutionContext.java:1216) at org.eclipse.birt.report.engine.executor.QueryItemExecutor.executeQuery(QueryItemExecutor.java:96) at org.eclipse.birt.report.engine.executor.TableItemExecutor.execute(TableItemExecutor.java:62) at org.eclipse.birt.report.engine.internal.executor.dup.SuppressDuplicateItemExecutor.execute(SuppressDuplicateItemExecutor.java:43) at org.eclipse.birt.report.engine.internal.executor.wrap.WrappedReportItemExecutor.execute(WrappedReportItemExecutor.java:46) at org.eclipse.birt.report.engine.internal.executor.l18n.LocalizedReportItemExecutor.execute(LocalizedReportItemExecutor.java:34) at org.eclipse.birt.report.engine.layout.html.HTMLBlockStackingLM.layoutNodes(HTMLBlockStackingLM.java:65) at org.eclipse.birt.report.engine.layout.html.HTMLStackingLM.layoutChildren(HTMLStackingLM.java:26) at org.eclipse.birt.report.engine.layout.html.HTMLAbstractLM.layout(HTMLAbstractLM.java:140) at org.eclipse.birt.report.engine.layout.html.HTMLInlinestackingLM.resumeLayout(HTMLInlinestackingLM.java:111) at org.eclipse.birt.report.engine.layout.html.HTMLInlinestackingLM.layoutNodes(HTMLInlinestackingLM.java:160) at org.eclipse.birt.report.engine.layout.html.HTMLStackingLM.layoutChildren(HTMLStackingLM.java:26) at org.eclipse.birt.report.engine.layout.html.HTMLAbstractLM.layout(HTMLAbstractLM.java:140) at org.eclipse.birt.report.engine.layout.html.HTMLBlockStackingLM.layoutNodes(HTMLBlockStackingLM.java:70) at org.eclipse.birt.report.engine.layout.html.HTMLStackingLM.layoutChildren(HTMLStackingLM.java:26) at org.eclipse.birt.report.engine.layout.html.HTMLTableLM.layoutChildren(HTMLTableLM.java:132) at org.eclipse.birt.report.engine.layout.html.HTMLAbstractLM.layout(HTMLAbstractLM.java:140) at org.eclipse.birt.report.engine.layout.html.HTMLBlockStackingLM.layoutNodes(HTMLBlockStackingLM.java:70) at org.eclipse.birt.report.engine.layout.html.HTMLPageLM.layout(HTMLPageLM.java:92) at org.eclipse.birt.report.engine.layout.html.HTMLReportLayoutEngine.layout(HTMLReportLayoutEngine.java:100) at org.eclipse.birt.report.engine.api.impl.RunAndRenderTask.doRun(RunAndRenderTask.java:180) at org.eclipse.birt.report.engine.api.impl.RunAndRenderTask.run(RunAndRenderTask.java:77) at org.eclipse.birt.report.service.ReportEngineservice.runAndRenderReport(ReportEngineservice.java:929) at org.eclipse.birt.report.service.BirtViewerReportService.runAndRenderReport(BirtViewerReportService.java:973) at org.eclipse.birt.report.service.actionhandler.BirtRunAndRenderActionHandler.__execute(BirtRunAndRenderActionHandler.java:76) at org.eclipse.birt.report.service.actionhandler.AbstractBaseActionHandler.execute(AbstractBaseActionHandler.java:90) at org.eclipse.birt.report.presentation.aggregation.layout.EngineFragment.doService(EngineFragment.java:318) at org.eclipse.birt.report.presentation.aggregation.AbstractBaseFragment.service(AbstractBaseFragment.java:76) at org.eclipse.birt.report.servlet.BirtEngineservlet.__doGet(BirtEngineservlet.java:120) at org.eclipse.birt.report.servlet.BaseReportEngineservlet.doGet(BaseReportEngineservlet.java:185) at javax.servlet.http.HttpServlet.service(HttpServlet.java:617) at org.apache.axis.transport.http.AxisServletBase.service(AxisServletBase.java:327) at javax.servlet.http.HttpServlet.service(HttpServlet.java:717) at org.eclipse.birt.report.servlet.BaseReportEngineservlet.service(BaseReportEngineservlet.java:116) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) at org.eclipse.birt.report.filter.ViewerFilter.doFilter(ViewerFilter.java:68) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:298) at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:859) at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:588) at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489) at java.lang.Thread.run(Thread.java:662) Caused by: org.eclipse.birt.report.data.adapter.api.AdapterException: An exception occurred during processing. Please see the following message for details: Cannot open the connection for the driver: org.eclipse.birt.report.data.oda.jdbc. org.eclipse.birt.report.data.oda.jdbc.JDBCException: Cannot load JDBC Driver class: com.MysqL.jdbc.Driver. at org.eclipse.birt.report.data.adapter.impl.DataRequestSessionImpl.execute(DataRequestSessionImpl.java:644) at org.eclipse.birt.report.engine.data.dte.DteDataEngine.doExecuteQuery(DteDataEngine.java:158) at org.eclipse.birt.report.engine.data.dte.AbstractDataEngine.execute(AbstractDataEngine.java:267) at org.eclipse.birt.report.engine.executor.ExecutionContext.executeQuery(ExecutionContext.java:1939) at org.eclipse.birt.report.engine.executor.QueryItemExecutor.executeQuery(QueryItemExecutor.java:80) ... 47 more Caused by: org.eclipse.birt.data.engine.odaconsumer.OdaDataException: Cannot open the connection for the driver: org.eclipse.birt.report.data.oda.jdbc. org.eclipse.birt.report.data.oda.jdbc.JDBCException: Cannot load JDBC Driver class: com.MysqL.jdbc.Driver. at org.eclipse.birt.data.engine.odaconsumer.ExceptionHandler.newException(ExceptionHandler.java:54) at org.eclipse.birt.data.engine.odaconsumer.ConnectionManager.openConnection(ConnectionManager.java:177) at org.eclipse.birt.data.engine.executor.DataSource.newConnection(DataSource.java:224) at org.eclipse.birt.data.engine.executor.DataSource.open(DataSource.java:212) at org.eclipse.birt.data.engine.impl.DataSourceRuntime.openOdiDataSource(DataSourceRuntime.java:217) at org.eclipse.birt.data.engine.impl.QueryExecutor.openDataSource(QueryExecutor.java:407) at org.eclipse.birt.data.engine.impl.QueryExecutor.prepareExecution(QueryExecutor.java:317) at org.eclipse.birt.data.engine.impl.PreparedQuery.doPrepare(PreparedQuery.java:455) at org.eclipse.birt.data.engine.impl.PreparedDataSourceQuery.produceQueryResults(PreparedDataSourceQuery.java:190) at org.eclipse.birt.data.engine.impl.PreparedDataSourceQuery.execute(PreparedDataSourceQuery.java:178) at org.eclipse.birt.data.engine.impl.PreparedOdaDSQuery.execute(PreparedOdaDSQuery.java:145) at org.eclipse.birt.report.data.adapter.impl.DataRequestSessionImpl.execute(DataRequestSessionImpl.java:624) ... 51 more Caused by: org.eclipse.birt.report.data.oda.jdbc.JDBCException: Cannot load JDBC Driver class: com.MysqL.jdbc.Driver. at org.eclipse.birt.report.data.oda.jdbc.JDBCDriverManager.findDriver(JDBCDriverManager.java:836) at org.eclipse.birt.report.data.oda.jdbc.JDBCDriverManager.loadAndRegisterDriver(JDBCDriverManager.java:941) at org.eclipse.birt.report.data.oda.jdbc.JDBCDriverManager.loadAndRegisterDriver(JDBCDriverManager.java:918) at org.eclipse.birt.report.data.oda.jdbc.JDBCDriverManager.doConnect(JDBCDriverManager.java:266) at org.eclipse.birt.report.data.oda.jdbc.JDBCDriverManager.getConnection(JDBCDriverManager.java:232) at org.eclipse.birt.report.data.oda.jdbc.Connection.connectByUrl(Connection.java:243) at org.eclipse.birt.report.data.oda.jdbc.Connection.open(Connection.java:162) at org.eclipse.datatools.connectivity.oda.consumer.helper.OdaConnection.open(OdaConnection.java:250) at org.eclipse.birt.data.engine.odaconsumer.ConnectionManager.openConnection(ConnectionManager.java:165) ... 61 more
我的情况有点特别,因为我不知道我是否做得恰到好处.我自己解释一下.
我有一些使用BIRT 2.6设计的报告和其他一些使用BIRT 3.7设计的报告.我在Tomcat服务器上所做的是我创建了两个存储库:
– birt-viewer
– birt-viewer3.7
我把MysqL驱动程序(mysql-connector-java-5.0.8-bin.jar)文件放在birt-viewer3.7 / WEB-INF / lib /中.
但我仍然有错误.我也尝试将它放在birt-viewer3.7 / WEB-INF / platform / plugins /中,但错误仍然相同.
首先:是否有可能使两个版本的birt-viewer共存?
如果可能,我该怎么做才能解决这个驱动问题?
谢谢.
解决方法
java – 在Tomcat环境下无法获取MySQL的JDBC驱动程序
工作站在Linux,Fedora 10上运行.
我已经通过CLI为Java手动设置了classpath变量,如下所示:
bash-3.2$echo $CLAsspATH /home/cmao/public_html/jsp/mysql-connector-java-5.1.12-bin.jar
这表明我已经将最新的MysqL连接jar存档添加到我的CLAsspATH变量中.
我已经创建了一个测试JSP页面,可以找到here
此页面的源代码是:
<%@page language="java"%> <%@page import="java.sql.*"%> <%@page import="java.util.*"%> <html> <head> <title>UTS JDBC MysqL connection test page</title> </head> <body> <% Connection con = null; out.print("Java version is : " + System.getProperty("java.version") + "<br />"); out.print("Tomcat version is : " + application.getServerInfo() + "<br />"); out.print("Servlet version is: " + application.getMajorVersion() + "<br />"); out.print("JSP version is : " + JspFactory.getDefaultFactory().getEngineInfo().getSpecificationVersion() +"<br />"); //out.print("Java classpath is : " + System.getProperty("java.class.path")+ "<br />"); //out.print("JSP classpath is : " + appliaction.getAttribute("org.apache.catalina.jsp_classpath") + "<br />"); //out.print("Tomcat classpath is : " + System.getProperty("org.apache.tomcat.common.classpath") + "<br />"); try { Class c = Class.forName("com.MysqL.jdbc.Driver"); } catch(Exception e) { out.println("Error! Failed to obtain JDBC driver for MysqL... Missing class \"com.MysqL.jdbc.Driver\"<br />"); } %> </body> </html>
这些注释掉的线都没有用,各种Jsper Expetions都会被抛出.
您可以从以下链接中检查这些错误页面:
classpath Error page
catalina Error page
tomcat Error page
看来,根据我对JSP和Servlet的有限知识,Tomcat环境“忽略”了我的Java CLAsspATH?在这种情况下,我无法配置MysqL JDBC包以使我的Servlet(JSP无论如何都是一个Servlet)工作.
我不知道如何解决这个问题.如果我使用像Eclipse或NetBeans这样的IDE并创建一个真正的Java“Web应用程序”,以便通过使用web.config XML配置文件来“自我配置”,那会更好吗?这样我可以绕过这个Tomcat环境限制吗?
非常感谢您提前提出的建议.
解决方法
This shows that I’ve added the lastest
MysqL connection jar archive to my
CLAsspATH variable.
太糟糕了,Tomcat(和所有其他Java EE应用服务器)忽略任何系统CLAsspATH环境变量.
您应该在以下两个位置之一添加JDBC驱动程序JAR:
>您的Web上下文的WEB-INF / lib,
这意味着它只适用于
你的应用程序(可能不是一件坏事)
>如果您使用的是版本5.x,则在Tomcat服务器/ lib中使用版本5.x或/ lib.
我相信Tomcat 6.x要求您将JDBC驱动程序JAR放在/ lib中.
java – 我无法加载MySQL的JDBC驱动程序
我一直在尝试使用以下代码加载JDBC MySQL连接器:
import java.sql.*;
public class dbTest{
public static void main(String[] args) throws sqlException,ClassNotFoundException
{
Class.forName("com.MysqL.jdbc.Driver");
}
}
我一直得到一个没有找到的例外:
java.lang.classNotFoundException
at edu.rice.cs.plt.reflect.PathClassLoader.findClass(PathClassLoader.java:148)
at java.lang.classLoader.loadClass(UnkNown Source)
at java.lang.classLoader.loadClass(UnkNown Source)
at java.lang.class.forName0(Native Method)
at java.lang.class.forName(UnkNown Source)
at dbTest.main(dbTest.java:6)
我已将驱动程序的路径(mysql-connector-java-3.1.14-bin.jar)添加到我的类路径中并进行了双重检查以确保它是正确的.我还根据我从本文中读到的内容将jar的副本添加到Java安装的ext文件夹中:http://www.developer.com/java/data/jdbc-and-mysql-installation-and-preparation-of-mysql.html
我还搜索了遇到此问题的其他人的帖子,但到目前为止所有的回复都说过要将连接器jar添加到类路径中,我已经完成了.
任何帮助将不胜感激.
I have added the path to the driver
(mysql-connector-java-3.1.14-bin.jar)
to my classpath
例外情况告诉您,您没有正确执行此操作.
你是如何设置CLAsspATH的?如果它是一个环境变量,您将学习IDE和应用服务器忽略它.不要使用它.
不要将它放在Java JDK的/ ext目录中.
正确的方法取决于你如何使用它:
>如果您在Eclipse或IntelliJ等IDE中运行,则必须将JAR添加到库中.
>如果您在命令shell中运行,则在编译时使用-p选项,并在运行时使用java.exe.
>如果您在Web应用程序中使用它,则可以将其放在WAR文件的WEB-INF / lib目录中.如果您正在使用像Tomcat 6这样的servlet / JSP引擎,请将其放在Tomcat / lib目录中.
今天的关于无法为连接URL'null'创建类''的JDBC驱动程序:Tomcat&SQL Server JDBC驱动程序和无法创建链接服务器null的ole db访问接口的分享已经结束,谢谢您的关注,如果想了解更多关于Java JDBC - 如何使用JDBC驱动程序通过代理连接到MySQL、java – BIRT JDBCException“无法加载JDBC驱动程序类:com.mysql.jdbc.Driver”从2.6升级到3.7、java – 在Tomcat环境下无法获取MySQL的JDBC驱动程序、java – 我无法加载MySQL的JDBC驱动程序的相关知识,请在本站进行查询。
本文标签: