gpt4 book ai didi

mysql - 错误 pool.ConnectionPool - 无法创建池的初始连接

转载 作者:太空宇宙 更新时间:2023-11-03 10:46:23 24 4
gpt4 key购买 nike

我是 Grails 新手。在 Datasource.groovy 中进行一些基本配置后,我的 grails 应用程序无法启动。我收到以下错误

Error 2015-07-03 15:27:19,014 [localhost-startStop-1] ERROR pool.ConnectionPool  - Unable to create initial connections of pool.

消息:Driver:org.h2.Driver@78f95cf6 为 URL:jdbc:mysql://localhost:3306/radb?createDatabaseIfNotExist=true 返回空值

|错误 2015-07-03 15:27:19,854 [localhost-startStop-1] 错误 context.GrailsContextLoaderListener - 初始化应用程序时出错:创建名为“transactionManagerPostProcessor”的 bean 时出错:bean 初始化失败;嵌套异常是 org.springframework.beans.factory.BeanCreationException:创建名为“transactionManager”的 bean 时出错:在设置 bean 属性“sessionFactory”时无法解析对 bean“sessionFactory”的引用;嵌套异常是 org.springframework.beans.factory.BeanCreationException:创建名为“sessionFactory”的 bean 时出错:调用 init 方法失败;嵌套异常是 java.lang.NullPointerException

数据库radb 存在。我已经验证过了

我的 Datasource.groovy 文件如下所示

dataSource {
pooled = true
jmxExport = true
driverClassName = "org.h2.Driver"
dialect = "org.hibernate.dialect.MySQL5InnoDBDialect"
//username = "sa"
//password = ""
}
hibernate {
cache.use_second_level_cache = true
cache.use_query_cache = false
// cache.region.factory_class = 'net.sf.ehcache.hibernate.EhCacheRegionFactory' // Hibernate 3
cache.region.factory_class = 'org.hibernate.cache.ehcache.EhCacheRegionFactory' // Hibernate 4
singleSession = true // configure OSIV singleSession mode
flush.mode = 'manual' // OSIV session flush mode outside of transactional context
}

// environment specific settings
environments {
development {
dataSource {
dbCreate = "create-drop" // one of 'create', 'create-drop', 'update', 'validate', ''
url = "jdbc:mysql://localhost:3306/radb?createDatabaseIfNotExist=true"
username="root"
password="root"
logSql = true
}
}
test {
dataSource {
dbCreate = "update"
url = "jdbc:h2:mem:testDb;MVCC=TRUE;LOCK_TIMEOUT=10000;DB_CLOSE_ON_EXIT=FALSE"
}
}
production {
dataSource {
dbCreate = "update"
url = "jdbc:h2:prodDb;MVCC=TRUE;LOCK_TIMEOUT=10000;DB_CLOSE_ON_EXIT=FALSE"
properties {
// See http://grails.org/doc/latest/guide/conf.html#dataSource for documentation
jmxEnabled = true
initialSize = 5
maxActive = 50
minIdle = 5
maxIdle = 25
maxWait = 10000
maxAge = 10 * 60000
timeBetweenEvictionRunsMillis = 5000
minEvictableIdleTimeMillis = 60000
validationQuery = "SELECT 1"
validationQueryTimeout = 3
validationInterval = 15000
testOnBorrow = true
testWhileIdle = true
testOnReturn = false
jdbcInterceptors = "ConnectionState"
defaultTransactionIsolation = java.sql.Connection.TRANSACTION_READ_COMMITTED
}
}
}
}

最佳答案

您的 driverClassName 是错误的。对 mysql 使用正确的(在环境中,例如 com.mysql.jdbc.Driver),您需要 mysql。现在你有:

default: driver=h2, dialect=mysql; 
dev: url=mysql
prod: url=h2

你绝对想清理它。还要确保你的部门有司机。

关于mysql - 错误 pool.ConnectionPool - 无法创建池的初始连接,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31204498/

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