-
Notifications
You must be signed in to change notification settings - Fork 338
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Is Connection.setSchema() (JDBC4) supported? #9
Comments
hi, setSchema() is supported by 0.9.5-pre3-SNAPSHOT. If you are seeing an AbstractMethodError in 0.9.5-pre3-SNAPSHOT, it is likely because your driver fails to support the method. The error you report above was, I'd be willing to bet, generated under 0.9.2.x or a previous version. Here's a very similar error, generated under 0.9.5-pre3-SNAPSHOT against postgresql-8.2-504.jdbc3.jar: java.lang.AbstractMethodError: org.postgresql.jdbc3.Jdbc3Connection.setSchema(Ljava/lang/String;)V Note the distinction -- under 0.9.5-pre3, the abstract method error still occurs but in the JDBC driver's Connection object rather than in com.mchange.v2.c3p0.impl.NewProxyConnection. With a more recent postgres driver, postgresql-9.2-1002.jdbc4.jar, the error is only slightly more informative: java.sql.SQLFeatureNotSupportedException: Method org.postgresql.jdbc4.Jdbc4Connection.setSchema(String) is not yet implemented. Please recheck under 0.9.5-pre3-SNAPSHOT. Verify that the build you are running is indeed a 0.9.5-pre3-SNAPSHOT [look in your logs for a line like "Initializing c3p0-0.9.5-pre3"], and inspect the error message carefully. Are you sure the AbstractMethodError you see is coming from com.mchange.v2.c3p0.impl.NewProxyConnection rather than a JDBC driver class? c3p0-0.9.5-pre3 should support all JDK 1.7 / JDBC 4 methods now, but only if the underlying driver also supports them. |
I ran a new build of my project and I confirm it uses 0.9.5-pre3-SNAPSHOT. Here are the log lines from c3p0's startup:
I'm using HSQL 2.2.9 and, if I read it's javadoc correctly (http://hsqldb.org/doc/2.0/apidocs/org/hsqldb/jdbc/JDBCConnection.html), it should implement setSchema. The first line of the error is still:
This project also uses Hibernate (4.2) and Spring Framework (3.2) so maybe some other dependency is causing the problem... If it helps, I can try to create a small project with the same dependencies to reproduce the error. Below is the full stack trace of one such error:
|
hi, if you can send a small demonstration, that would be fantastic. setSchema( ... ) really is in the generated code for NewProxyConnection, and when i call the method, it clearly does get through the c3p0 layer (only to fail at my underlying driver ). so this is very puzzling. |
I managed to make a demonstration project for this error. It is available here https://github.com/edysli/c3p0_AbstractMethodError_demo. Run mvn test (on Java 7) and the exception should appear. Looks like you already fixed it though; I accidentally ran Maven with --update-snapshots, it downloaded a new snapshot and I got a different exception. :) I can still trigger the AbstractMethodError with 0.9.5-pre2. |
Wow. You are right. A quick javap confirms that c3p0-0.9.5-pre2's NewProxyConnection includes only JDBC3 methods, while c3p0-0.9.5-pre1 and c3p0-0.9.5-pre3-SNAPSHOT properly includes all JDK1.7 methods. I'm not sure how this happened; I must have had an JDBC library somehow shadow JDBC4 libs when I built, although that should be hard since c3p0-0.9.5-preX won't build in anything but 1.7. This build quirk may remain a mystery, but I'll go ahead and make c3p0-0.9.5-pre3 a release to cover up the shame and embarrassment. :) And I'll be sure to test for the presence of JDBC4 methods going forward. Thank you for the demo project. I had to edit the aspectj.version property to 1.7.2 rather than 1.7.2-RELEASE, but other than that it worked fine. (Of course I played around with c3p0 versions.) Except for in -pre2, the error I'm now getting is org.hibernate.exception.SQLGrammarException inside hsqldb libs. |
Thank you for fixing it! :) |
Hi,
I've tried using Connection.setSchema() in my code but got an AbstractMethodError exception:
This occurs with version 0.9.5-pre2 and 0.9.5-pre3-SNAPSHOT.
So is Connection.setSchema() supposed to be supported?
The text was updated successfully, but these errors were encountered: