使用cayenne模块在java和mysql之间连接时出错

时间:2013-07-03 06:34:11

标签: java mysql apache-cayenne

Jul 03, 2013 9:19:08 AM org.apache.cayenne.configuration.XMLDataChannelDescriptorLoader load
INFO: Loading XML configuration resource from file:/C:/Users/Shadi/Documents/spring%20tool%20projects/myBookstore/target/classes/cayenne-project.xml
Jul 03, 2013 9:19:08 AM org.apache.cayenne.configuration.XMLDataChannelDescriptorLoader$DataSourceChildrenHandler createChildTagHandler
INFO: loading user name and password.
Jul 03, 2013 9:19:08 AM org.apache.cayenne.log.CommonsJdbcEventLogger logPoolCreated
INFO: Created connection pool: jdbc:mysql://localhost/bookstore
    Driver class: com.mysql.jdbc.Driver
    Min. connections in the pool: 1
    Max. connections in the pool: 1
Jul 03, 2013 9:19:08 AM org.apache.cayenne.log.CommonsJdbcEventLogger logConnectFailure
INFO: *** Connecting: FAILURE.
java.sql.SQLException: Can not load JDBC driver named 'com.mysql.jdbc.Driver': com.mysql.jdbc.Driver
    at org.apache.cayenne.conn.DriverDataSource.loadDriver(DriverDataSource.java:60)
    at org.apache.cayenne.conn.DriverDataSource.setDriverClassName(DriverDataSource.java:254)
    at org.apache.cayenne.conn.DriverDataSource.<init>(DriverDataSource.java:99)
    at org.apache.cayenne.conn.DriverDataSource.<init>(DriverDataSource.java:85)
    at org.apache.cayenne.conn.PoolManager.<init>(PoolManager.java:90)
    at org.apache.cayenne.configuration.server.XMLPoolingDataSourceFactory.getDataSource(XMLPoolingDataSourceFactory.java:64)
    at org.apache.cayenne.configuration.server.DelegatingDataSourceFactory.getDataSource(DelegatingDataSourceFactory.java:68)
    at org.apache.cayenne.configuration.server.DataDomainProvider.createAndInitDataDomain(DataDomainProvider.java:203)
    at org.apache.cayenne.configuration.server.DataDomainProvider.get(DataDomainProvider.java:111)
    at org.apache.cayenne.configuration.server.DataDomainProvider.get(DataDomainProvider.java:58)
    at org.apache.cayenne.di.spi.CustomProvidersProvider.get(CustomProvidersProvider.java:38)
    at org.apache.cayenne.di.spi.FieldInjectingProvider.get(FieldInjectingProvider.java:42)
    at org.apache.cayenne.di.spi.DefaultScopeProvider.get(DefaultScopeProvider.java:49)
    at org.apache.cayenne.di.spi.DefaultInjector.getInstance(DefaultInjector.java:107)
    at org.apache.cayenne.di.spi.FieldInjectingProvider.injectMember(FieldInjectingProvider.java:93)
    at org.apache.cayenne.di.spi.FieldInjectingProvider.injectMembers(FieldInjectingProvider.java:58)
    at org.apache.cayenne.di.spi.FieldInjectingProvider.get(FieldInjectingProvider.java:43)
    at org.apache.cayenne.di.spi.DefaultScopeProvider.get(DefaultScopeProvider.java:49)
    at org.apache.cayenne.di.spi.DefaultInjector.getInstance(DefaultInjector.java:103)
    at org.apache.cayenne.configuration.CayenneRuntime.getContext(CayenneRuntime.java:182)
    at mybookstore.Main.main(Main.java:23)

Exception in thread "main" org.apache.cayenne.configuration.server.DataDomainLoadException: [v.3.1M3 Sep 12 2011 19:59:45] Error loading DataChannel: 'Can not load JDBC driver named 'com.mysql.jdbc.Driver': com.mysql.jdbc.Driver'
    at org.apache.cayenne.configuration.server.DataDomainProvider.get(DataDomainProvider.java:117)
    at org.apache.cayenne.configuration.server.DataDomainProvider.get(DataDomainProvider.java:58)
    at org.apache.cayenne.di.spi.CustomProvidersProvider.get(CustomProvidersProvider.java:38)
    at org.apache.cayenne.di.spi.FieldInjectingProvider.get(FieldInjectingProvider.java:42)
    at org.apache.cayenne.di.spi.DefaultScopeProvider.get(DefaultScopeProvider.java:49)
    at org.apache.cayenne.di.spi.DefaultInjector.getInstance(DefaultInjector.java:107)
    at org.apache.cayenne.di.spi.FieldInjectingProvider.injectMember(FieldInjectingProvider.java:93)
    at org.apache.cayenne.di.spi.FieldInjectingProvider.injectMembers(FieldInjectingProvider.java:58)
    at org.apache.cayenne.di.spi.FieldInjectingProvider.get(FieldInjectingProvider.java:43)
    at org.apache.cayenne.di.spi.DefaultScopeProvider.get(DefaultScopeProvider.java:49)
    at org.apache.cayenne.di.spi.DefaultInjector.getInstance(DefaultInjector.java:103)
    at org.apache.cayenne.configuration.CayenneRuntime.getContext(CayenneRuntime.java:182)
    at mybookstore.Main.main(Main.java:23)
Caused by: java.sql.SQLException: Can not load JDBC driver named 'com.mysql.jdbc.Driver': com.mysql.jdbc.Driver
    at org.apache.cayenne.conn.DriverDataSource.loadDriver(DriverDataSource.java:60)
    at org.apache.cayenne.conn.DriverDataSource.setDriverClassName(DriverDataSource.java:254)
    at org.apache.cayenne.conn.DriverDataSource.<init>(DriverDataSource.java:99)
    at org.apache.cayenne.conn.DriverDataSource.<init>(DriverDataSource.java:85)
    at org.apache.cayenne.conn.PoolManager.<init>(PoolManager.java:90)
    at org.apache.cayenne.configuration.server.XMLPoolingDataSourceFactory.getDataSource(XMLPoolingDataSourceFactory.java:64)
    at org.apache.cayenne.configuration.server.DelegatingDataSourceFactory.getDataSource(DelegatingDataSourceFactory.java:68)
    at org.apache.cayenne.configuration.server.DataDomainProvider.createAndInitDataDomain(DataDomainProvider.java:203)
    at org.apache.cayenne.configuration.server.DataDomainProvider.get(DataDomainProvider.java:111)
    ... 12 more

请帮帮我

2 个答案:

答案 0 :(得分:1)

此回复适用于仍然面临此问题的人。

我遇到了同样的问题。我发现了以下修复(Courtsey“Andrus”发布在nabble.com)。这解决了我的oracle问题。

从CayenneModeler GUI连接时是否收到此错误?

如果需要,您需要转到“工具 - &gt;首选项 - &gt; ClassPath”并点击
在“添加Jar / Zip”按钮上,导航到Oracle驱动程序jar文件(a 像ojdbc14.jar这样的文件。将路径添加到驱动程序后,单击
“保存”,你应该能够连接。

来源:http://cayenne.195.n3.nabble.com/Problem-connecting-oracle-10-td718.html

我认为他在nabble.com上回复得更好。我可以在我之前看到他的帖子! ;)

答案 1 :(得分:0)

确保mysql驱动程序jar在应用程序的类路径上