まったく構成されていない、新しい Grails 2.3.0 アプリがありますgrails create-app
。groovy.sql.Sql
コードがまったく機能していないようで、常に次の sql エラーが発生することがわかりました。
java.sql.SQLException: No suitable driver found forjdbc:h2:mem:devDb;MVCC=TRUE;LOCK_TIMEOUT=10000
No suitable driver found
エラーの原因となるコードの例を次に示しますBootStrap.groovy
。繰り返しますが、これは新しいアプリに追加される唯一のコードです。
import groovy.sql.Sql
class BootStrap {
def grailsApplication
def init = { servletContext ->
try {
def sql = Sql.newInstance(grailsApplication.config.dataSource.url, grailsApplication.config.dataSource.username, grailsApplication.config.dataSource.password, grailsApplication.config.dataSource.driverClassName)
sql.execute("create table newtable")
}
catch(java.sql.SQLException ex) {
throw ex
}
}
def destroy = {
}
}
問題を次のデフォルト設定まで追跡したと思いgrails.project.fork
ます。それらをコメントアウトすると、すべてが正常に機能し、テーブルが正常に作成されます。
grails.project.fork = [
// configure settings for compilation JVM, note that if you alter the Groovy version forked compilation is required
// compile: [maxMemory: 256, minMemory: 64, debug: false, maxPerm: 256, daemon:true],
// configure settings for the test-app JVM, uses the daemon by default
test: [maxMemory: 768, minMemory: 64, debug: false, maxPerm: 256, daemon:true],
// configure settings for the run-app JVM
run: [maxMemory: 768, minMemory: 64, debug: false, maxPerm: 256, forkReserve:false],
// configure settings for the run-war JVM
war: [maxMemory: 768, minMemory: 64, debug: false, maxPerm: 256, forkReserve:false],
// configure settings for the Console UI JVM
console: [maxMemory: 768, minMemory: 64, debug: false, maxPerm: 256]
]
フォークされた jvm は groovy sql クラスの接続をブロックしますか? ここで何が起こっているのか理解できないようです。