尝试使用Play Framework连接到Sybase时,UnimplementedOperationException

时间:2012-03-02 00:47:00

标签: playframework sybase c3p0

我使用application.conf中的以下配置配置了一个新的Play Framework应用程序以连接到现有的Sybase数据库:

# 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

我在无处可寻的地方寻找解决方案。有没有人见过这个?任何方式让它工作? (我确信我不能成为第一个在Play Framework中使用Sybase的人......)

1 个答案:

答案 0 :(得分:1)

jConnect 6没有实现getDatabaseMajorVersion(),并且c3p0出于某种原因依赖于此方法。

使用jConnect 7或jTDS,你很好。