Grails中如何把hsqldb数据库改为mysql
展开全部
你可以通过如下几步连接
首先,将Mysql的驱动即jar包放到自己项目的lib文件夹下(驱动下载:http://www.mysql.com/products/connector/j/)
第二,创建数据库。 通过MySQL Server下的MySQL Command Line Client创建。如下所示:
Enter password: **** //MySql的密码
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 5 to server version: 5.0.20-nt
Type 'help;' or '\h' for help. Type '\c' to clear the buffer.
mysql> create database **** //××××为创建的数据库名字
这样在Mysql里就生成了××××数据库
最后,就是..\grails-app\conf下DataSource.groovy的配置。配置如下:
DatadataSource {
pooled = false
// driverClassName = "org.hsqldb.jdbcDriver"
driverClassName = "com.mysql.jdbc.Driver" //一般情况下将org改成com
username = "mysql用户名"
password = "密码"
}
hibernate {
cache.use_second_level_cache=true
cache.use_query_cache=true
cache.provider_class='org.hibernate.cache.EhCacheProvider'
}
// environment specific settings
environments {
development {
dataSource {
dbCreate = "update" // one of 'create', 'create-drop','update'
url = "jdbc:mysql://localhost/××××?useUnicode=true&characterEncoding=UTF8"
}
}
//下面的可不用管
test {
dataSource {
dbCreate = "update"
url = "jdbc:mysql://localhost/jp_ad_sys?useUnicode=true&characterEncoding=UTF8"
}
}
首先,将Mysql的驱动即jar包放到自己项目的lib文件夹下(驱动下载:http://www.mysql.com/products/connector/j/)
第二,创建数据库。 通过MySQL Server下的MySQL Command Line Client创建。如下所示:
Enter password: **** //MySql的密码
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 5 to server version: 5.0.20-nt
Type 'help;' or '\h' for help. Type '\c' to clear the buffer.
mysql> create database **** //××××为创建的数据库名字
这样在Mysql里就生成了××××数据库
最后,就是..\grails-app\conf下DataSource.groovy的配置。配置如下:
DatadataSource {
pooled = false
// driverClassName = "org.hsqldb.jdbcDriver"
driverClassName = "com.mysql.jdbc.Driver" //一般情况下将org改成com
username = "mysql用户名"
password = "密码"
}
hibernate {
cache.use_second_level_cache=true
cache.use_query_cache=true
cache.provider_class='org.hibernate.cache.EhCacheProvider'
}
// environment specific settings
environments {
development {
dataSource {
dbCreate = "update" // one of 'create', 'create-drop','update'
url = "jdbc:mysql://localhost/××××?useUnicode=true&characterEncoding=UTF8"
}
}
//下面的可不用管
test {
dataSource {
dbCreate = "update"
url = "jdbc:mysql://localhost/jp_ad_sys?useUnicode=true&characterEncoding=UTF8"
}
}
本回答被提问者和网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询