getSerial(): Incompatible cast to IfmxStatement
Posted in 2007
Topics: Connectivity: ODBC / JDBC / .NET
Hi, I'm trying to get a serial after an insert in an informix database. My code does the following: import com.informix.jdbc.*; ... /* mystmt makes the insert */ mystmt.executeUpdate(); int result = ((IfmxStatement)mystmt).getSerial(); When I deploy this on a websphere 6.x application server and run the application, I get the following exception: com.ibm.ws.rsadapter.jdbc.WSJdbcPreparedStatement incompatible with com.informix.jdbc.IfmxStatement What am I doing wrong? Thanks in advance, Pedro
"pedro" <pedro.e.santo@gmail.com> schrieb im Newsbeitrag news:1185891297.147294.297280@d55g2000hsg.googlegroups.com... > Hi, > > I'm trying to get a serial after an insert in an informix database. > > My code does the following: > > > import com.informix.jdbc.*; > > ... > > /* mystmt makes the insert */ > mystmt.executeUpdate(); > > int result = ((IfmxStatement)mystmt).getSerial(); > Hi there, I dont think that your problem has to do with Informix. You just cant cast a WS wrapper statement to a native jdbc statement like that. Take a look at com.ibm.websphere.rsadapter.WSCallHelper This class is for calling non-standard methods of jdbc drivers and should do the trick. Alternatively you could as well issue a select dbinfo('sqlca.sqlerrd1') from systables where tabid=1 after the insert to get the last serial Dirk
On Jul 31, 7:34 pm, "Dirk Gunsth'vel" <d...@guncon.de> wrote: > "pedro" <pedro.e.sa...@gmail.com> schrieb im Newsbeitragnews:1185891297.147294.297280@d55g2000hsg.googlegroups.com... > > > > > Hi, > > > I'm trying to get a serial after an insert in an informix database. > > > My code does the following: > > > import com.informix.jdbc.*; > > > ... > > > /* mystmt makes the insert */ > > mystmt.executeUpdate(); > > > int result = ((IfmxStatement)mystmt).getSerial(); > > Hi there, > > I dont think that your problem has to do with Informix. You just > cant cast a WS wrapper statement to a native jdbc statement > like that. > > Take a look at > com.ibm.websphere.rsadapter.WSCallHelper > > This class is for calling non-standard methods of jdbc drivers > and should do the trick. > > Alternatively you could as well issue a > select dbinfo('sqlca.sqlerrd1') from systables where tabid=1 > after the insert to get the last serial > > Dirk use the getGeneratedKeys() method. it is a standard JDBC method, available in 1.4.2 (if not even earlier). It returns a ResultSet object, which means you will have to iterate it to get all the various keys (i.e. Serial). Zachi