我是Java的初学者,我正在尝试运行一个GWT应用程序,这不是我编写的,但我知道代码应该正常工作。使用gwt:run
启动开发服务器时,一切似乎都有效,但没有数据库连接,我收到了JDBC错误。
[ERROR] kwi 21, 2018 3:54:08 AM java.util.prefs.WindowsPreferences <init>
[ERROR] WARNING: Could not open/create prefs root node Software\JavaSoft\Prefs at root 0x80000002. Windows RegCreateKeyEx(...) returned error code 5.
[INFO] 2018-04-21 03:54:11,805 ERROR Could not perform database startup operations using logging manager [jdbcManager{ description=databaseAppender, bufferSize=0, connectionSource=factory{ public static java.sql.Connection com.mcrawler.crawler.database.ConnectionFactory.getDatabaseConnection() }, tableName=EventLog, columns=[ { name=eventDate, layout=null, literal=null, timestamp=true }, { name=level, layout=%level, literal=null, timestamp=false }, { name=logger, layout=%logger, literal=null, timestamp=false }, { name=message, layout=%message, literal=null, timestamp=false }, { name=exception, layout=%ex{full}, literal=null, timestamp=false } ] }]. java.sql.SQLException: Failed to obtain connection from factory method.
[INFO] at org.apache.logging.log4j.core.appender.db.jdbc.FactoryMethodConnectionSource$1.getConnection(FactoryMethodConnectionSource.java:107)
[INFO] at org.apache.logging.log4j.core.appender.db.jdbc.FactoryMethodConnectionSource.getConnection(FactoryMethodConnectionSource.java:53)
[INFO] at org.apache.logging.log4j.core.appender.db.jdbc.JdbcDatabaseManager.startupInternal(JdbcDatabaseManager.java:60)
[INFO] at org.apache.logging.log4j.core.appender.db.AbstractDatabaseManager.startup(AbstractDatabaseManager.java:64)
[INFO] at org.apache.logging.log4j.core.appender.db.AbstractDatabaseAppender.start(AbstractDatabaseAppender.java:89)
[INFO] at org.apache.logging.log4j.core.config.AbstractConfiguration.start(AbstractConfiguration.java:168)
[INFO] at org.apache.logging.log4j.core.LoggerContext.setConfiguration(LoggerContext.java:359)
[INFO] at org.apache.logging.log4j.core.LoggerContext.reconfigure(LoggerContext.java:420)
[INFO] at org.apache.logging.log4j.core.LoggerContext.start(LoggerContext.java:138)
[INFO] at org.apache.logging.log4j.core.impl.Log4jContextFactory.getContext(Log4jContextFactory.java:147)
[INFO] at org.apache.logging.log4j.core.impl.Log4jContextFactory.getContext(Log4jContextFactory.java:41)
[INFO] at org.apache.logging.log4j.LogManager.getContext(LogManager.java:175)
[INFO] at org.apache.logging.log4j.spi.AbstractLoggerAdapter.getContext(AbstractLoggerAdapter.java:102)
[INFO] at org.apache.logging.slf4j.Log4jLoggerFactory.getContext(Log4jLoggerFactory.java:43)
[INFO] at org.apache.logging.log4j.spi.AbstractLoggerAdapter.getLogger(AbstractLoggerAdapter.java:42)
[INFO] at org.apache.logging.slf4j.Log4jLoggerFactory.getLogger(Log4jLoggerFactory.java:29)
[INFO] at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:285)
[INFO] at org.eclipse.jetty.util.log.Slf4jLog.<init>(Slf4jLog.java:38)
[INFO] at org.eclipse.jetty.util.log.Slf4jLog.<init>(Slf4jLog.java:32)
[INFO] at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
[INFO] at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
[INFO] at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
[INFO] at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
[INFO] at java.lang.Class.newInstance(Class.java:442)
[INFO] at org.eclipse.jetty.util.log.Log.initialized(Log.java:161)
[INFO] at org.eclipse.jetty.util.log.Log.getLogger(Log.java:435)
[INFO] at org.eclipse.jetty.util.log.Log.getLogger(Log.java:425)
[INFO] at org.eclipse.jetty.servlet.listener.ELContextCleaner.<clinit>(ELContextCleaner.java:43)
[INFO] at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
[INFO] at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
[INFO] at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
[INFO] at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
[INFO] at java.lang.Class.newInstance(Class.java:442)
[INFO] at org.eclipse.jetty.server.handler.ContextHandler$Context.createListener(ContextHandler.java:2375)
[INFO] at org.eclipse.jetty.servlet.ServletContextHandler$Context.createListener(ServletContextHandler.java:1227)
[INFO] at org.eclipse.jetty.webapp.StandardDescriptorProcessor.newListenerInstance(StandardDescriptorProcessor.java:1908)
[INFO] at org.eclipse.jetty.webapp.StandardDescriptorProcessor.visitListener(StandardDescriptorProcessor.java:1865)
[INFO] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
[INFO] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
[INFO] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
[INFO] at java.lang.reflect.Method.invoke(Method.java:498)
[INFO] at org.eclipse.jetty.webapp.IterativeDescriptorProcessor.visit(IterativeDescriptorProcessor.java:85)
[INFO] at org.eclipse.jetty.webapp.IterativeDescriptorProcessor.process(IterativeDescriptorProcessor.java:72)
[INFO] at org.eclipse.jetty.webapp.MetaData.resolve(MetaData.java:366)
[INFO] at org.eclipse.jetty.webapp.WebAppContext.startContext(WebAppContext.java:1240)
[INFO] at org.eclipse.jetty.server.handler.ContextHandler.doStart(ContextHandler.java:717)
[INFO] at org.eclipse.jetty.webapp.WebAppContext.doStart(WebAppContext.java:494)
[INFO] at com.google.gwt.dev.shell.jetty.JettyLauncher$WebAppContextWithReload.doStart(JettyLauncher.java:541)
[INFO] at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:64)
[INFO] at org.eclipse.jetty.server.handler.HandlerWrapper.doStart(HandlerWrapper.java:95)
[INFO] at org.eclipse.jetty.server.handler.RequestLogHandler.doStart(RequestLogHandler.java:165)
[INFO] at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:64)
[INFO] at org.eclipse.jetty.server.handler.HandlerWrapper.doStart(HandlerWrapper.java:95)
[INFO] at org.eclipse.jetty.server.Server.doStart(Server.java:282)
[INFO] at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:64)
[INFO] at com.google.gwt.dev.shell.jetty.JettyLauncher.start(JettyLauncher.java:740)
[INFO] at com.google.gwt.dev.DevMode.doStartUpServer(DevMode.java:522)
[INFO] at com.google.gwt.dev.DevModeBase.startUp(DevModeBase.java:1104)
[INFO] at com.google.gwt.dev.DevModeBase.run(DevModeBase.java:844)
[INFO] at com.google.gwt.dev.DevMode.main(DevMode.java:322)
[INFO] Caused by: java.lang.reflect.InvocationTargetException
[INFO] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
[INFO] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
[INFO] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
[INFO] at java.lang.reflect.Method.invoke(Method.java:498)
[INFO] at org.apache.logging.log4j.core.appender.db.jdbc.FactoryMethodConnectionSource$1.getConnection(FactoryMethodConnectionSource.java:105)
[INFO] ... 59 more
[INFO] Caused by: com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException: Could not create connection to database server.
[INFO] at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
[INFO] at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
[INFO] at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
[INFO] at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
[INFO] at com.mysql.jdbc.Util.handleNewInstance(Util.java:377)
[INFO] at com.mysql.jdbc.Util.getInstance(Util.java:360)
[INFO] at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:956)
[INFO] at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:935)
[INFO] at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:924)
[INFO] at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:870)
[INFO] at com.mysql.jdbc.ConnectionImpl.connectOneTryOnly(ConnectionImpl.java:2311)
[INFO] at com.mysql.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:2064)
[INFO] at com.mysql.jdbc.ConnectionImpl.<init>(ConnectionImpl.java:790)
[INFO] at com.mysql.jdbc.JDBC4Connection.<init>(JDBC4Connection.java:44)
[INFO] at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
[INFO] at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
[INFO] at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
[INFO] at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
[INFO] at com.mysql.jdbc.Util.handleNewInstance(Util.java:377)
[INFO] at com.mysql.jdbc.ConnectionImpl.getInstance(ConnectionImpl.java:395)
[INFO] at com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:325)
[INFO] at java.sql.DriverManager.getConnection(DriverManager.java:664)
[INFO] at java.sql.DriverManager.getConnection(DriverManager.java:247)
[INFO] at org.apache.commons.dbcp.DriverManagerConnectionFactory.createConnection(DriverManagerConnectionFactory.java:75)
[INFO] at org.apache.commons.dbcp.PoolableConnectionFactory.makeObject(PoolableConnectionFactory.java:582)
[INFO] at org.apache.commons.pool.impl.GenericObjectPool.borrowObject(GenericObjectPool.java:1188)
[INFO] at org.apache.commons.dbcp.PoolingDataSource.getConnection(PoolingDataSource.java:106)
[INFO] at com.mcrawler.crawler.database.ConnectionFactory.getDatabaseConnection(ConnectionFactory.java:51)
[INFO] ... 64 more
[INFO] Caused by: java.lang.NullPointerException
[INFO] at com.mysql.jdbc.ConnectionImpl.getServerCharset(ConnectionImpl.java:2983)
[INFO] at com.mysql.jdbc.MysqlIO.sendConnectionAttributes(MysqlIO.java:1873)
[INFO] at com.mysql.jdbc.MysqlIO.proceedHandshakeWithPluggableAuthentication(MysqlIO.java:1802)
[INFO] at com.mysql.jdbc.MysqlIO.doHandshake(MysqlIO.java:1206)
[INFO] at com.mysql.jdbc.ConnectionImpl.coreConnect(ConnectionImpl.java:2234)
[INFO] at com.mysql.jdbc.ConnectionImpl.connectOneTryOnly(ConnectionImpl.java:2265)
[INFO] ... 81 more
[INFO]
[INFO] 2018-04-21 03:54:12,036 ERROR Could not perform database startup operations using logging manager [jdbcManager{ description=databaseAppender, bufferSize=0, connectionSource=factory{ public static java.sql.Connection com.mcrawler.crawler.database.ConnectionFactory.getDatabaseConnection() }, tableName=EventLog, columns=[ { name=eventDate, layout=null, literal=null, timestamp=true }, { name=level, layout=%level, literal=null, timestamp=false }, { name=logger, layout=%logger, literal=null, timestamp=false }, { name=message, layout=%message, literal=null, timestamp=false }, { name=exception, layout=%ex{full}, literal=null, timestamp=false } ] }]. java.sql.SQLException: Failed to obtain connection from factory method.
[INFO] at org.apache.logging.log4j.core.appender.db.jdbc.FactoryMethodConnectionSource$1.getConnection(FactoryMethodConnectionSource.java:107)
[INFO] at org.apache.logging.log4j.core.appender.db.jdbc.FactoryMethodConnectionSource.getConnection(FactoryMethodConnectionSource.java:53)
[INFO] at org.apache.logging.log4j.core.appender.db.jdbc.JdbcDatabaseManager.startupInternal(JdbcDatabaseManager.java:60)
[INFO] at org.apache.logging.log4j.core.appender.db.AbstractDatabaseManager.startup(AbstractDatabaseManager.java:64)
[INFO] at org.apache.logging.log4j.core.appender.db.AbstractDatabaseAppender.start(AbstractDatabaseAppender.java:89)
[INFO] at org.apache.logging.log4j.core.config.AbstractConfiguration.start(AbstractConfiguration.java:168)
[INFO] at org.apache.logging.log4j.core.LoggerContext.setConfiguration(LoggerContext.java:359)
[INFO] at org.apache.logging.log4j.core.LoggerContext.reconfigure(LoggerContext.java:420)
[INFO] at org.apache.logging.log4j.core.LoggerContext.start(LoggerContext.java:138)
[INFO] at org.apache.logging.log4j.core.impl.Log4jContextFactory.getContext(Log4jContextFactory.java:147)
[INFO] at org.apache.logging.log4j.core.impl.Log4jContextFactory.getContext(Log4jContextFactory.java:41)
[INFO] at org.apache.logging.log4j.LogManager.getContext(LogManager.java:262)
[INFO] at org.apache.log4j.Logger$PrivateManager.getContext(Logger.java:59)
[INFO] at org.apache.log4j.Logger.getLogger(Logger.java:37)
[INFO] at org.apache.commons.logging.impl.Log4JLogger.getLogger(Log4JLogger.java:262)
[INFO] at org.apache.commons.logging.impl.Log4JLogger.<init>(Log4JLogger.java:108)
[INFO] at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
[INFO] at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
[INFO] at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
[INFO] at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
[INFO] at org.apache.commons.logging.impl.LogFactoryImpl.createLogFromClass(LogFactoryImpl.java:1025)
[INFO] at org.apache.commons.logging.impl.LogFactoryImpl.discoverLogImplementation(LogFactoryImpl.java:844)
[INFO] at org.apache.commons.logging.impl.LogFactoryImpl.newInstance(LogFactoryImpl.java:541)
[INFO] at org.apache.commons.logging.impl.LogFactoryImpl.getInstance(LogFactoryImpl.java:292)
[INFO] at org.apache.commons.logging.impl.LogFactoryImpl.getInstance(LogFactoryImpl.java:269)
[INFO] at org.apache.commons.logging.LogFactory.getLog(LogFactory.java:657)
[INFO] at org.apache.jasper.servlet.JspServlet.<clinit>(JspServlet.java:58)
[INFO] at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
[INFO] at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
[INFO] at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
[INFO] at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
[INFO] at java.lang.Class.newInstance(Class.java:442)
[INFO] at org.eclipse.jetty.servlet.ServletContextHandler$Context.createServlet(ServletContextHandler.java:1075)
[INFO] at org.eclipse.jetty.servlet.ServletHolder.newInstance(ServletHolder.java:957)
[INFO] at org.eclipse.jetty.servlet.ServletHolder.initServlet(ServletHolder.java:514)
[INFO] at org.eclipse.jetty.servlet.ServletHolder.doStart(ServletHolder.java:344)
[INFO] at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:64)
[INFO] at org.eclipse.jetty.servlet.ServletHandler.initialize(ServletHandler.java:791)
[INFO] at org.eclipse.jetty.servlet.ServletContextHandler.startContext(ServletContextHandler.java:265)
[INFO] at org.eclipse.jetty.webapp.WebAppContext.startContext(WebAppContext.java:1242)
[INFO] at org.eclipse.jetty.server.handler.ContextHandler.doStart(ContextHandler.java:717)
[INFO] at org.eclipse.jetty.webapp.WebAppContext.doStart(WebAppContext.java:494)
[INFO] at com.google.gwt.dev.shell.jetty.JettyLauncher$WebAppContextWithReload.doStart(JettyLauncher.java:541)
[INFO] at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:64)
[INFO] at org.eclipse.jetty.server.handler.HandlerWrapper.doStart(HandlerWrapper.java:95)
[INFO] at org.eclipse.jetty.server.handler.RequestLogHandler.doStart(RequestLogHandler.java:165)
[INFO] at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:64)
[INFO] at org.eclipse.jetty.server.handler.HandlerWrapper.doStart(HandlerWrapper.java:95)
[INFO] at org.eclipse.jetty.server.Server.doStart(Server.java:282)
[INFO] at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:64)
[INFO] at com.google.gwt.dev.shell.jetty.JettyLauncher.start(JettyLauncher.java:740)
[INFO] at com.google.gwt.dev.DevMode.doStartUpServer(DevMode.java:522)
[INFO] at com.google.gwt.dev.DevModeBase.startUp(DevModeBase.java:1104)
[INFO] at com.google.gwt.dev.DevModeBase.run(DevModeBase.java:844)
[INFO] at com.google.gwt.dev.DevMode.main(DevMode.java:322)
[INFO] Caused by: java.lang.reflect.InvocationTargetException
[INFO] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
[INFO] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
[INFO] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
[INFO] at java.lang.reflect.Method.invoke(Method.java:498)
[INFO] at org.apache.logging.log4j.core.appender.db.jdbc.FactoryMethodConnectionSource$1.getConnection(FactoryMethodConnectionSource.java:105)
[INFO] ... 54 more
[INFO] Caused by: com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException: Could not create connection to database server.
[INFO] at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
[INFO] at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
[INFO] at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
[INFO] at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
[INFO] at com.mysql.jdbc.Util.handleNewInstance(Util.java:377)
[INFO] at com.mysql.jdbc.Util.getInstance(Util.java:360)
[INFO] at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:956)
[INFO] at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:935)
[INFO] at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:924)
[INFO] at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:870)
[INFO] at com.mysql.jdbc.ConnectionImpl.connectOneTryOnly(ConnectionImpl.java:2311)
[INFO] at com.mysql.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:2064)
[INFO] at com.mysql.jdbc.ConnectionImpl.<init>(ConnectionImpl.java:790)
[INFO] at com.mysql.jdbc.JDBC4Connection.<init>(JDBC4Connection.java:44)
[INFO] at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
[INFO] at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
[INFO] at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
[INFO] at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
[INFO] at com.mysql.jdbc.Util.handleNewInstance(Util.java:377)
[INFO] at com.mysql.jdbc.ConnectionImpl.getInstance(ConnectionImpl.java:395)
[INFO] at com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:325)
[INFO] at java.sql.DriverManager.getConnection(DriverManager.java:664)
[INFO] at java.sql.DriverManager.getConnection(DriverManager.java:247)
[INFO] at org.apache.commons.dbcp.DriverManagerConnectionFactory.createConnection(DriverManagerConnectionFactory.java:75)
[INFO] at org.apache.commons.dbcp.PoolableConnectionFactory.makeObject(PoolableConnectionFactory.java:582)
[INFO] at org.apache.commons.pool.impl.GenericObjectPool.borrowObject(GenericObjectPool.java:1188)
[INFO] at org.apache.commons.dbcp.PoolingDataSource.getConnection(PoolingDataSource.java:106)
[INFO] at com.mcrawler.crawler.database.ConnectionFactory.getDatabaseConnection(ConnectionFactory.java:51)
[INFO] ... 59 more
[INFO] Caused by: java.lang.NullPointerException
[INFO] at com.mysql.jdbc.ConnectionImpl.getServerCharset(ConnectionImpl.java:2983)
[INFO] at com.mysql.jdbc.MysqlIO.sendConnectionAttributes(MysqlIO.java:1873)
[INFO] at com.mysql.jdbc.MysqlIO.proceedHandshakeWithPluggableAuthentication(MysqlIO.java:1802)
[INFO] at com.mysql.jdbc.MysqlIO.doHandshake(MysqlIO.java:1206)
[INFO] at com.mysql.jdbc.ConnectionImpl.coreConnect(ConnectionImpl.java:2234)
[INFO] at com.mysql.jdbc.ConnectionImpl.connectOneTryOnly(ConnectionImpl.java:2265)
[INFO] ... 76 more
我安装了MySQL并使用crawldb
用户创建了数据库root
。 root用户的密码为password
。我可以从shell登录MySQL,可以看到数据库。以下是应用程序代码,它似乎指定了连接设置:
<hibernate-configuration>
<session-factory>
<!-- MySQL localhost -->
<property name='connection.driver_class'>com.mysql.jdbc.Driver</property>
<property name='connection.url'>jdbc:mysql://localhost:3306/crawldb</property>
<property name='connection.username'>root</property>
<property name='connection.password'>password</property>
<property name='dialect'>org.hibernate.dialect.MySQLDialect</property>
<!-- JDBC connection pool (use the built-in) -->
<property name="c3p0.min_size">3</property>
<property name="c3p0.max_size">15</property>
<property name="c3p0.acquire_increment">2</property>
<property name="c3p0.idle_test_period">3000</property>
<property name="c3p0.max_statements">50</property>
<property name="c3p0.timeout">1800</property>
<!-- Enable Hibernate's automatic session context management -->
<property name="current_session_context_class">thread</property>
<!-- Disable the second-level cache -->
<property name="hibernate.cache.use_second_level_cache">false</property>
<!-- Echo all executed SQL to stdout -->
<property name="show_sql">false</property>
<property name="default_batch_fetch_size">128</property>
<property name="jdbc.batch_size">24</property>
</session-factory>
</hibernate-configuration>
在pom.xml
中,mysql-connector-java依赖于:
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>5.1.34</version>
</dependency>
答案 0 :(得分:1)
正如Mark Rotteveel在评论中所建议的那样,我的pom.xml
中的Connector / J版本与我系统上安装的MySQL版本(8.0.11)相比已经很旧了(5.1.34),结果是是一个多变的组合。
解决方案是使用较新版本的Connector / J或降级我的机器上的MySQL版本。我最终选择了后者并安装了MySQL 5.5,因为我需要在不修改任何项目文件的情况下运行应用程序。