####################################
# Database Connectivity Properties
####################################
#hsql
#driver=org.hsqldb.jdbcDriver
#url=jdbc:hsqldb:mem:jgamestore
#username=sa
#password=
#mysql
driver=com.mysql.jdbc.Driver
url=jdbc:mysql://localhost:3306/JGAMESTORE?autoReconnect=true
username=jgamestore
password=ibatis9977
#oracle
#driver=oracle.jdbc.driver.OracleDriver
#url=jdbc:oracle:thin:@//localhost:1521:goodinb
#username=jgamestore
#password=ibatis9977
2.下载一个mysql-connector-java-5.0.4-bin.jar文件,并拷贝到iia-jgamestore的lib目录下。
3.使用MySql客户端(我使用的是EMS SQL Manager 2005 for MySQL)创建JGAMESTORE数据库。然后依次运行src/ddl/mysql目录下的jgamestore-mysql-schema.sql、jgamestore-mysql-create-user.sql、jgamestore-mysql-dataload.sql三个文件,填充数据。
你可以通过如下几步连接
首先,将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"
}
}
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)