Mysql Grails或Hibernate不创建缺少的表
我是Grails新手,所以请原谅我的无知——如果其他信息有帮助,我会尽我所能将其发布 我创建了一个域模型类Mysql Grails或Hibernate不创建缺少的表,mysql,grails,gorm,grails-domain-class,grails-2.0,Mysql,Grails,Gorm,Grails Domain Class,Grails 2.0,我是Grails新手,所以请原谅我的无知——如果其他信息有帮助,我会尽我所能将其发布 我创建了一个域模型类ToolKitComponent,定义如下: class ToolKitComponent { String componentName String componentVersion int componentDownloads Date compnentLastUpdate static constraints = { } } 我有一
ToolKitComponent
,定义如下:
class ToolKitComponent {
String componentName
String componentVersion
int componentDownloads
Date compnentLastUpdate
static constraints = {
}
}
我有一个控制器,我只想通过持久化一个示例来测试ORM,下面是控制器的内容:
def index() {
ToolKitComponent i = new ToolKitComponent()
i.setComponentName("TestComponent")
i.setComponentVersion("v1.10")
i.setComponentDownloads(1)
i.setCompnentLastUpdate(new Date())
i.save()
}
我已安装MySql数据库插件,并将我的DataSource.groovy更新为:
dataSource {
pooled = true
driverClassName = "com.mysql.jdbc.Driver"
dialect = "org.hibernate.dialect.MySQL5InnoDBDialect"
loggingSql = true
}
// other settings
environments {
development {
dataSource {
String dbCreate = "create"
String url = "jdbc:mysql://localhost/testDataBase"
String username = "myUser"
String password = "myPass"
}
}
}
我已经创建了数据库testDataBase
,并将所有内容都授予用户名
当我运行应用程序时,我得到:
Hibernate: insert into tool_kit_component (version, compnent_last_update, component_downloads, component_name, component_version) values (?, ?, ?, ?, ?)
| Error 2012-07-11 20:01:52,727 [http-bio-8080-exec-2] ERROR util.JDBCExceptionReporter - Table "TOOL_KIT_COMPONENT" not found; SQL statement:
insert into tool_kit_component (version, compnent_last_update, component_downloads, component_name, component_version) values (?, ?, ?, ?, ?) [42102-164]
| Error 2012-07-11 20:01:52,752 [http-bio-8080-exec-2] ERROR errors.GrailsExceptionResolver - JdbcSQLException occurred when processing request: [GET] /TestProject/
Table "TOOL_KIT_COMPONENT" not found; SQL statement:
insert into tool_kit_component (version, compnent_last_update, component_downloads, component_name, component_version) values (?, ?, ?, ?, ?) [42102-164]. Stacktrace follows:
Message: Table "TOOL_KIT_COMPONENT" not found; SQL statement:
insert into tool_kit_component (version, compnent_last_update, component_downloads, component_name, component_version) values (?, ?, ?, ?, ?) [42102-164]
Line | Method
->> 329 | getJdbcSQLException in org.h2.message.DbException
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
| 169 | get in ''
| 146 | get . . . . . . . . in ''
| 4753 | readTableOrView in org.h2.command.Parser
| 4731 | readTableOrView . . in ''
| 954 | parseInsert in ''
| 375 | parsePrepared . . . in ''
| 279 | parse in ''
| 251 | parse . . . . . . . in ''
| 217 | prepareCommand in ''
| 415 | prepareLocal . . . in org.h2.engine.Session
| 364 | prepareCommand in ''
| 1121 | prepareCommand . . in org.h2.jdbc.JdbcConnection
| 71 | <init> in org.h2.jdbc.JdbcPreparedStatement
| 267 | prepareStatement . in org.h2.jdbc.JdbcConnection
| 1051 | prepareStatement in ''
| 508 | prepareStatement . in org.apache.commons.dbcp.DelegatingConnection
| 400 | prepareStatement in org.apache.commons.dbcp.PoolingDataSource$PoolGuardConnectionWrapper
| 11 | index . . . . . . . in TestProject.HomeController
| 1110 | runWorker in java.util.concurrent.ThreadPoolExecutor
| 603 | run . . . . . . . . in java.util.concurrent.ThreadPoolExecutor$Worker
^ 722 | run in java.lang.Thread
Hibernate:插入工具箱组件(版本、组件上次更新、组件下载、组件名称、组件版本)值(?、、、?、?)
|错误2012-07-11 20:01:52727[http-bio-8080-exec-2]错误util.jdbceptionReporter-未找到表“工具箱组件”;SQL语句:
在工具包组件(版本、组件上次更新、组件下载、组件名称、组件版本)中插入值(?,,,,,,?)[42102-164]
|错误2012-07-11 20:01:52752[http-bio-8080-exec-2]错误。GrailExceptionResolver-处理请求[GET]/TestProject时发生JdbcSQLException/
未找到表“工具箱组件”;SQL语句:
在工具包组件(版本、组件上次更新、组件下载、组件名称、组件版本)中插入值(?、、、?、?)[42102-164]。跟踪如下:
消息:未找到“工具箱组件”表;SQL语句:
在工具包组件(版本、组件上次更新、组件下载、组件名称、组件版本)中插入值(?,,,,,,?)[42102-164]
直线法
->>329 | org.h2.message.DbException中的getJdbcSQLException
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|169“上车”
|146 |获得。在“
|4753 | org.h2.command.Parser中的readTableOrView
|4731 | readTableOrView。在“
|954 |在“”中插入
|375 |已准备好。在“
|279 |在“”中解析
|251 |解析。在“
|217 |在“”中准备命令
|415 |准备本地。在org.h2.engine.Session中
|364 |在“”中准备命令
|1121 |准备命令。在org.h2.jdbc.JdbcConnection中
|71 |在org.h2.jdbc.jdbc preparedstatement中
|267 |准备陈述。在org.h2.jdbc.JdbcConnection中
|1051 |在“”中准备陈述
|508 |准备陈述。在org.apache.commons.dbcp.DelegatingConnection中
|400 | org.apache.commons.dbcp.PoolgDataSource$PoolGuardConnectionWrapper中的prepareStatement
|11 |索引。在TestProject.HomeController中
|1110 | java.util.concurrent.ThreadPoolExecutor中的runWorker
|603 |运行。在java.util.concurrent.ThreadPoolExecutor$Worker中
^722 |在java.lang.Thread中运行
我正在使用Grails2.0.4
感谢您的帮助 去掉数据源定义中的
字符串
environments {
development {
dataSource {
dbCreate = "create"
url = "jdbc:mysql://localhost/testDataBase"
username = "myUser"
password = "myPass"
}
}
}