30842

c3p0 ResultSet.unwrap throws an AbstractMethodError

I have a ResultSet object that I need to turn into an OracleResultSet so that I can call the getOPAQUE(String) method on it. I'm using c3p0 as my connection pool. The problem is that c3p0 wraps ResultSets in NewProxyResultSet objects.

This shouldn't be a problem because I should just be able to call unwrap on the ResultSet like this:

rs.unwrap(OracleResultSet.class)

However, that doesn't work. It actually throws an AbstractMethodError:

java.lang.AbstractMethodError: com.mchange.v2.c3p0.impl.NewProxyResultSet.unwrap(Ljava/lang/Class;)Ljava/lang/Object;

It includes a stack trace, but it's not helpful because the top line of the stack trace just points to the exact line on which I call the unwrap method. That seems to indicate that NewProxyResultSet itself does not have unwrap implemented.

What's up with this? How can I take a NewProxyResultSet and get an OracleResultSet from it?

Answer1:

I figured out a way to get the inner value! It's a hack, but it works. If anyone knows a more portable way of getting the inner value (like making the unwrap method work) then I'd love to do that instead.

But, it turns out that the "inner" variable of the NewProxyResultSet is declared protected. So I just make a class in the same package as NewProxyResultSet and use it to get the inner value like so:

package com.mchange.v2.c3p0.impl; import java.sql.ResultSet; /** * This is a sneaky way to get at the inner ResultSet of NewProxyResultSet. It marks the variable as protected, * so here I just make a class in the same package and get the value out. * */ public class C3P0ResultSetPeeker { public static ResultSet getInnerFrom(NewProxyResultSet rs) { return rs.inner; } }

Recommend

  • Maven Release Plugin Issue - Failed to execute goal org.apache.maven.plugins:maven-release-plugin:2.
  • android compability problem
  • PDFStamper fails on several PDF files (itext 5.5.1)
  • proto2 with Spark cannot run
  • Does javac also inline?
  • phase unwrap issue (the unwrapping of the phases is not correcly)?
  • Why does my println in rdd prints the string of elements?
  • Parse JSON value as Enum in Rust
  • Can't figure out a function to return a reference to a given type stored in RefCell
  • Is it possible to specialize on a static lifetime?
  • Complex trait requirements on struct
  • Are Richfaces and Primefaces compatible with each other?
  • Get a trait object reference from a vector
  • Authentication failed with Azure Active Directory in Windows Phone
  • Creating Java object from class name with constructor, which contains parameters [duplicate]
  • Debug.DrawLine not showing in the GameView
  • How to use RequestBodyAdvice
  • CSS Linear-gradient formatting issue accross different browsers
  • Spring Data JPA custom method causing PropertyReferenceException
  • Can I display google adwords (AdView) in javafx on android
  • Array.prototype.includes - not transformed with babel
  • Align navbar back button on right side
  • How to add date and time under each post in guestbook in google app engine
  • How to set/get protobuf's extension field in Go?
  • DirectX11 ClearRenderTargetViewback with transparent buffer?
  • Validaiting emails with Net.Mail MailAddress
  • sending/ receiving email in Java
  • Display Images one by one with next and previous functionality
  • Web-crawler for facebook in python
  • Akka Routing: Reply's send to router ends up as dead letters
  • R: gsub and capture
  • jqPlot EnhancedLegendRenderer plugin does not toggle series for Pie charts
  • Cannot Parse HTML Data Using Android / JSOUP
  • Comma separated Values
  • Java static initializers and reflection
  • unknown Exception android
  • Observable and ngFor in Angular 2
  • Unable to use reactive element in my shiny app
  • Python/Django TangoWithDjango Models and Databases
  • How to load view controller without button in storyboard?