So, I'm working in Java, Trying to cast a java.sql.ResultSet
to my own class MyResultSet
Here is the code: MyResultSet.java
public class MyResultSet implements java.sql.ResultSet{
//There are a bunch of Implemented Methods here. None of them have any custom code, They are all unchanged. Just didn't want to put huge code in here.
}
The code I'm trying to use to cast it
ResultSet r = getResultSet();
return (MyResultSet)r;
Whenever I run this, I get a "ClassCastException".
Could someone explain to me how to cast to an Implemented Class?..
getResultSet()
? – ImpeachablegetResultSet()
? – Hamesjava.sql.ResultSet
– Antisthenesjava.sql.ResultSet
. It's just example code. – LouvainResultSet
from aPreparedStatement
and I'd like it to be my class returned instead of the defaultjava.sql.ResultSet
.. – LouvainMyresultSet
) . – Impeachablepublic class MyResultSet implements java.sql.ResultSet{ private ResultSet thisIsTheWrappedResultSet; }
– AraucaniaMyresultSet
class and in that pass the object ofResultSet
obtained. Thereafter you can add various property or functionality to the values obtained from thatresultSe
t object according to your convinience. – Impeachable