UnimplementedOperationException при попытке подключения к Sybase с Play Framework
Я настроил новое приложение Play Framework для подключения к существующей базе данных Sybase, используя следующую конфигурацию в application.conf
:
# If you need a full JDBC configuration use the following :
db.url=jdbc:sybase:Tds:tkfixdbt1.mycompany.com:4100/user_u
db.driver=com.sybase.jdbc3.jdbc.SybDriver
db.user=user
db.pass=pass
# Specify the custom JPA dialect to use here (default to guess):
jpa.dialect=org.hibernate.dialect.Sybase11Dialect
# Specify the ddl generation pattern to use. Set to none to disable it
# (default to update in DEV mode, and none in PROD mode):
jpa.ddl=none
# Debug SQL statements (logged using DEBUG level):
jpa.debugSQL=true
Когда я запускаю приложение с некоторыми @Entity
модельные классы в models
пакет, я получаю следующую трассировку стека исключений:
09:14:40,097 INFO ~ Listening for HTTP on port 9099 (Waiting a first request to start) ...
09:15:41,943 INFO ~ Connected to jdbc:sybase:Tds:tkfixdbt1:4100/user_u
09:15:42,943 WARN ~ Could not obtain connection metadata
java.sql.SQLException: An SQLException was provoked by the following failure: com.sybase.jdbc3.utils.UnimplementedOperationException: The method com.sybase.jdbc3.jdbc.SybDatabaseMetaData.getDatabaseMajorVersion() has not been completed and should not be called.
at com.mchange.v2.sql.SqlUtils.toSQLException(SqlUtils.java:106)
at com.mchange.v2.sql.SqlUtils.toSQLException(SqlUtils.java:65)
at com.mchange.v2.sql.SqlUtils.toSQLException(SqlUtils.java:62)
at com.mchange.v2.c3p0.impl.NewPooledConnection.handleThrowable(NewPooledConnection.java:432)
at com.mchange.v2.c3p0.impl.NewProxyDatabaseMetaData.getDatabaseMajorVersion(NewProxyDatabaseMetaData.java:3692)
at org.hibernate.cfg.SettingsFactory.buildSettings(SettingsFactory.java:117)
at org.hibernate.cfg.Configuration.buildSettingsInternal(Configuration.java:2833)
at org.hibernate.cfg.Configuration.buildSettings(Configuration.java:2829)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1840)
at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:902)
at play.db.jpa.JPAPlugin.onApplicationStart(JPAPlugin.java:229)
at play.plugins.PluginCollection.onApplicationStart(PluginCollection.java:425)
at play.Play.start(Play.java:495)
at play.Play.detectChanges(Play.java:599)
at play.Invoker$Invocation.init(Invoker.java:186)
at play.server.PlayHandler$NettyInvocation.init(PlayHandler.java:168)
at play.Invoker$Invocation.run(Invoker.java:263)
at play.server.PlayHandler$NettyInvocation.run(PlayHandler.java:200)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334)
at java.util.concurrent.FutureTask.run(FutureTask.java:166)
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(ScheduledThreadPoolExecutor.java:178)
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:292)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
at java.lang.Thread.run(Thread.java:722)
Caused by: com.sybase.jdbc3.utils.UnimplementedOperationException: The method com.sybase.jdbc3.jdbc.SybDatabaseMetaData.getDatabaseMajorVersion() has not been completed and should not be called.
at com.sybase.jdbc3.jdbc.ErrorMessage.raiseRuntimeException(Unknown Source)
at com.sybase.jdbc3.utils.Debug.notImplemented(Unknown Source)
at com.sybase.jdbc3.jdbc.SybDatabaseMetaData.getDatabaseMajorVersion(Unknown Source)
at com.mchange.v2.c3p0.impl.NewProxyDatabaseMetaData.getDatabaseMajorVersion(NewProxyDatabaseMetaData.java:3678)
... 21 more
09:15:45,130 ERROR ~
@69hc9n374
Internal Server Error (500) for request GET /
Oops: NullPointerException
An unexpected error occured caused by exception NullPointerException: null
play.exceptions.UnexpectedException: Unexpected Error
at play.Play.start(Play.java:525)
at play.Play.detectChanges(Play.java:599)
at play.Invoker$Invocation.init(Invoker.java:186)
at Invocation.HTTP Request(Play!)
Caused by: java.lang.NullPointerException
at org.hibernate.cfg.SettingsFactory.buildSettings(SettingsFactory.java:169)
at org.hibernate.cfg.Configuration.buildSettingsInternal(Configuration.java:2833)
at org.hibernate.cfg.Configuration.buildSettings(Configuration.java:2829)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1840)
at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:902)
at play.db.jpa.JPAPlugin.onApplicationStart(JPAPlugin.java:229)
at play.plugins.PluginCollection.onApplicationStart(PluginCollection.java:425)
at play.Play.start(Play.java:495)
... 3 more
Я искал решение этой проблемы везде, где только мог подумать, но безрезультатно. Кто-нибудь видел это? Есть ли способ заставить его работать? (Я уверен, что не могу быть первым человеком, когда-либо использовавшим Sybase с Play Framework...)
1 ответ
Решение
jConnect 6 не реализует getDatabaseMajorVersion() и c3p0 по какой-то причине использует этот метод.
Используйте jConnect 7 или jTDS, и вы в порядке.