grails(1.1.1)のgroovyで開発されたアプリケーションがあります。次のように、datasource.groovyコードスニペットでMySQLサーバーの休止状態の有効化プール構成データソースを使用しました-
hibernate {
cache.use_second_level_cache=true
cache.use_query_cache=true
cache.provider_class='com.opensymphony.oscache.hibernate.OSCacheProvider'
}
environments {
development {
dataSource {
logSql = true
dbCreate = "update" // one of 'create', 'create-drop','update'
url = "jdbc:mysql://<dev-server-ip>:3306/<db-name>"
}
}
test {
dataSource {
dbCreate = "update"
url = "jdbc:mysql://<test-server-ip>:3306/<db-name>"
}
}
production {
dataSource {
dbCreate = "update"
url = "jdbc:mysql://<prod-server-ip>:3306/<db-name>"
}
}
別のMSSQLServer2005に接続する場合。次の接続設定でサービスクラスを定義しました
def connection = Sql.newInstance(
"jdbc:sqlserver://<mssql-db-server-ip>;databaseName=<db-name>",
'<username>',
'<password>',
'com.microsoft.sqlserver.jdbc.SQLServerDriver')
この接続はプールされた接続ではないことを私は知っています。そして、この接続を使用してデータを取得するたびにセッションを作成します。それで、サービスクラスにプールされた接続を作成するメカニズムはありますか?
このmssqlサーバー接続を使用してサービスクラスからクエリを実行し、次のようなデータクエリを選択すると
String pullData() {
def userId = "sample_user"
def testData = connection.firstRow("select distinct (COLUMN_NAME1+' > '+replace(COLUMN_NAME2,' > ', '>')+' > '+COLUMN_NAME3+' > '+COLUMN_NAME4+' > '+EMAIL) testRow from VIEW_NAME where lower(substring(EMAIL,1,(select charindex('@',EMAIL))-1 )) = lower(?)",[userId])
def myStringList = testData.testRow.split(' > ')
def myTestDataList = myStringList[4].split('@')
def email = myTestDataList[0]
return email
}
例外が発生しました。スタックトレースは
org.codehaus.groovy.runtime.InvokerInvocationException: java.lang.reflect.UndeclaredThrowableException
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:646)
at org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:436)
at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:374)
at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:302)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at jcifs.http.NtlmHttpFilter.doFilter(NtlmHttpFilter.java:125)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:298)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:859)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:588)
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489)
at java.lang.Thread.run(Thread.java:636)
Caused by: java.lang.reflect.UndeclaredThrowableException
at PullDataService$$EnhancerByCGLIB$$881a39b3.pullData(<generated>)
at PullDataService$$FastClassByCGLIB$$f8a1c77f.invoke(<generated>)
at net.sf.cglib.proxy.MethodProxy.invoke(MethodProxy.java:149)
... 33 more
Caused by: com.microsoft.sqlserver.jdbc.SQLServerException: Connection timed out
at com.microsoft.sqlserver.jdbc.SQLServerConnection.terminate(SQLServerConnection.java:1368)
at com.microsoft.sqlserver.jdbc.SQLServerConnection.terminate(SQLServerConnection.java:1355)
at com.microsoft.sqlserver.jdbc.TDSChannel.write(IOBuffer.java:1548)
at com.microsoft.sqlserver.jdbc.TDSWriter.flush(IOBuffer.java:2368)
at com.microsoft.sqlserver.jdbc.TDSWriter.writePacket(IOBuffer.java:2270)
at com.microsoft.sqlserver.jdbc.TDSWriter.endMessage(IOBuffer.java:1877)
at com.microsoft.sqlserver.jdbc.TDSCommand.startResponse(IOBuffer.java:4403)
at com.microsoft.sqlserver.jdbc.SQLServerPreparedStatement.doExecutePreparedStatement(SQLServerPreparedStatement.java:386)
at com.microsoft.sqlserver.jdbc.SQLServerPreparedStatement$PrepStmtExecCmd.doExecute(SQLServerPreparedStatement.java:338)
at com.microsoft.sqlserver.jdbc.TDSCommand.execute(IOBuffer.java:4026)
at com.microsoft.sqlserver.jdbc.SQLServerConnection.executeCommand(SQLServerConnection.java:1416)
at com.microsoft.sqlserver.jdbc.SQLServerStatement.executeCommand(SQLServerStatement.java:185)
at com.microsoft.sqlserver.jdbc.SQLServerStatement.executeStatement(SQLServerStatement.java:160)
at com.microsoft.sqlserver.jdbc.SQLServerPreparedStatement.executeQuery(SQLServerPreparedStatement.java:281)
at PullDataService.pullData(PullDataService.groovy:38)
at PullDataService$$FastClassByCGLIB$$7ff09ca7.invoke(<generated>)
at net.sf.cglib.proxy.MethodProxy.invoke(MethodProxy.java:149)
... 40 more
私を助けてください、私は長い間それに苦しんでいます。どんな提案も認められます。前もって感謝します。