mysql 无法创建池的初始连接_错误pool.ConnectionPool - 无法创建池的初始连接(ERROR pool.ConnectionPool - Unable to create ini...

在配置DataSource.groovy后,Grails新手遇到应用启动问题,报错无法创建数据库连接池。错误信息指出驱动返回的URL为空。尽管数据库'radb'存在,但初始化连接失败。配置文件中设置了dataSource,包括开发、测试和生产环境的数据库连接参数,但启动时仍遇到NullPointerException。
摘要由CSDN通过智能技术生成

I am Grails newbie. After doing some basic configuration in Datasource.groovy, my grails app fails to start. I get the below error

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

Message: Driver:org.h2.Driver@78f95cf6 returned null for URL:jdbc:mysql://localhost:3306/radb?createDatabaseIfNotExist=true

| Error 2015-07-03 15:27:19,854 [localhost-startStop-1] ERROR context.GrailsContextLoaderListener - Error initializing the application: Error creating bean with name 'transactionManagerPostProcessor': Initialization of bean failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'transactionManager': Cannot resolve reference to bean 'sessionFactory' while setting bean property 'sessionFactory'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory': Invocation of init method failed; nested exception is java.lang.NullPointerException

The database radb exists. I have verified it

My Datasource.groovy file for reference as below

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

}

}

}

}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值