gpt4 book ai didi

mysql - org.apache.tomcat.dbcp.dbcp.SQLNestedException : Cannot create JDBC driver of class '' for connect URL 'null'

转载 作者:行者123 更新时间:2023-11-29 09:15:23 26 4
gpt4 key购买 nike

我正在使用 spring 、hybernate +jpa 开发一个基于 Web 的项目。我正在尝试使用 Atomkios 配置 JTA 事务 我的后端是mySql。我无法将应用程序设置为与 mySql 一起使用。 我的网络服务器是 tomcat 5.5。我正在尝试校准 jndi 配置的数据源..这里我的代码是

持久性.xml:

  <persistence-unit name="exhub" transaction-type="JTA">
<provider>org.hibernate.ejb.HibernatePersistence</provider>
<jta-data-source>java:comp/env/jdbc/exampleWeb</jta-data-source>
<mapping-file>META-INF/orm.xml</mapping-file>
<class>com.evolvus.common.model.Talogin</class>
<class>com.evolvus.common.model.TaUser</class>
-----------------
-----------------
<properties>
<property name="hibernate.transaction.manager_lookup_class"
value="com.atomikos.icatch.jta.hibernate3.TransactionManagerLookup"/>
</ properties>
</persistence-unit>
</persistence>

orm.xml:

<description>Evolvus Solutions</description> 
<package>com.evolvus.common.model</package>


<entity class="com.evolvus.common.model.TaUser" name="TaUser">
<table name="ta_user" />
<attributes>
<id name="userId">
<column name="USER_ID"/>
<generated-value strategy="TABLE" />
</id>
<basic name="userName">
<column name="USER_NAME" length="50" />
</basic>

</attributes>
</entity>
---------------
--------------
---------------

</entity-mappings>

配置.xml:

 <beans: bean id="sessionFactory"   
class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
<beans: property name="useTransactionAwareDataSource"
value="true" />
<beans: property name="hibernateProperties">
<beans: props>
<beans: prop key="hibernate.dialect">${database.target}</beans:prop>
<beans: prop key="hibernate.connection.isolation">3</beans:prop>
<beans: prop key="hibernate.current_session_context_class">jta</beans:prop>
<beans: prop key="hibernate.transaction.factory_class">com.atomikos.icatch.jta.hibernate3.AtomikosJTATransactionFactory
</beans: prop>
<beans: prop key="hibernate.transaction.manager_lookup_class">com.atomikos.icatch.jta.hibernate3.TransactionManagerLookup
</beans: prop>
<beans: prop key="hibernate.connection.release_mode">on_close</beans: prop>
<beans: prop key="hibernate.show_sql">false</beans: prop>
</beans: props>
</beans: property>
</beans: bean>

<beans: bean id="jpaTemplate" class="org.springframework.orm.jpa.JpaTemplate">
<beans: property name="entityManagerFactory">
<beans: ref bean="entityManagerFactory" />
</beans: property>
</beans: bean>
<beans: bean id="entityManagerFactory"
class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
<beans: property name="persistenceUnitName" value="payhub" />
<beans: property name="jpaVendorAdapter">
<beans:bean
class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter">
<beans: property name="generateDdl" value="false" />
<beans: property name="showSql" value="true" />
<beans: property name="databasePlatform" value="${database.target}" />
</beans: bean>
</beans: property>
<beans: property name="persistenceXmlLocation">
<beans: value>classpath:META-INF/persistence.xml</beans:value>
</beans: property>
</beans: bean>
</beans: beans>

我在tomcat 5.5中配置了jndi

Apache 软件基金会\Tomcat 5.5\conf.xml:

 <Resource
name="jdbc/exampleWeb"
type="javax.sql.DataSource"
maxActive="4"
maxIdle="2"
username="root"
maxWait="5000"
validationQuery="SELECT=1"
driverClassName="com.mysql.jdbc.Driver"
password="roopt"
url="jdbc\:mysql\://localhost\:3306/welcomeHub"/>

and my application\web.xml

<resource-ref>
<description>PaymentsDatabase</description>
<res-ref-name>jdbc/exampleWeb</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
<res-sharing-scope>Shareable</res-sharing-scope>
</resource-ref>

我的服务器运行良好,但当我尝试访问数据库数据时,我的网络浏览器中出现以下错误

org.springframework.jdbc.CannotGetJdbcConnectionException:无法获取 JDBC 连接;嵌套异常是 org.apache.tomcat.dbcp.dbcp.SQLNestedException:无法为连接 URL 'null' 创建类 '' 的 JDBC 驱动程序 org.springframework.jdbc.datasource.DataSourceUtils.getConnection(DataSourceUtils.java:82)

帮帮我

最佳答案

我认为您的应用程序找不到 mysql 连接器 jar 文件或者您的 url 配置错误。

尝试以下操作

  1. 将 mysql 连接器 jar 文件放在 tomcat/common/lib 下,以便在 webapp 类之前获取它。
  2. 更改您的 context.xml 以包含如下资源。



    <pre><code><Resource name="jdbc/exampleWeb"
    auth="Container"
    type="javax.sql.DataSource"
    maxActive="100"
    maxIdle="30"
    username="root"
    maxWait="10000"
    driverClassName="com.mysql.jdbc.Driver"
    password="roopt"
    url="jdbc:mysql://localhost:3306/welcomeHub"/>
    </code></pre>

关于mysql - org.apache.tomcat.dbcp.dbcp.SQLNestedException : Cannot create JDBC driver of class '' for connect URL 'null' ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4332339/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com