ResultSet error with Weblogic 5.1

Hi:

We are having some problems with some method of the Interface ResultSet

We have Weblogic 5.1 and a pool that connect to a Oracle DB 8.1.5 through an Oracle thin driver.

We make the connection to the pool and get a ResultSet rs.

In the loop that goes through the records I can get the information of the records but if I try the ResultSet Method:

rs.isLast();

I get a java.lang.NullPointerException

The reference to the object rs exists.

I can't use rs.next() to know if there are more records.

does anyone know why is this happening?

Thanks in advance,Marta.

[651 byte] By [martagle] at [2007-9-26 2:27:34]
# 1

I don't know exactly how r u using isLast() method. I might help you if you send your piece of code where you are using this method.

Otherwise if you want to process all the records of the resultset, you can use it in the loop as:-

while(rs.next())

{

xxxxxxxxxxxxxxxxx

xxxxxxxxxxxxxxxxx

}

chandan_p11 at 2007-6-29 9:41:59 > top of Java-index,Database Connectivity,Java Database Connectivity (JDBC)...
# 2

Here is some of the code I have:

ResultSet rs=vPs.executeQuery();

ResultSetMetaData rsMeta=rs.getMetaData();

int iContador=0;

for (int iEsperaPrimero=1;rs.next();iEsperaPrimero++)

{

if ((iEsperaPrimero>=iPrimero)&&(iContador!=iMaximo))

{

iContador++;

Hashtable hElemento=new Hashtable();

for (int iCont=1;iCont!=rsMeta.getColumnCount()+1;iCont++)

{

String sClave=rsMeta.getColumnName(iCont); hElemento.put (sClave, rs.getObject (iCont));

}

}

//here before exiting the loop I want to know if it is the last record

if(rs.isLast())

{

//MORE CODE

}

}//end of for loop1

Marta

martagle at 2007-6-29 9:41:59 > top of Java-index,Database Connectivity,Java Database Connectivity (JDBC)...
# 3

first you tell me what exactly you want to accomplish with the line :

for (int iEsperaPrimero=1;rs.next();iEsperaPrimero++)

because rs.next() also returns boolean.

instead you can do the following

while(rs.next())

{

-- your code in the for loop --

if(rs.isLast())

{

-- this is for handling the code in the isLast() method --

}

-- your code in the for loop --

}

try this out and tell me the result.

chandan_p11 at 2007-6-29 9:41:59 > top of Java-index,Database Connectivity,Java Database Connectivity (JDBC)...
# 4

we use the line:

for (int iEsperaPrimero=1;rs.next();iEsperaPrimero++)

instead of while(rs.next()) for the pagination.

I've tried to do what you said:

while(rs.next())

{

//code

if(rs.isLast())

{

//more code

}

}

and it's giving again a java.lang.NullPointerException in that line.

I've tried also rs.isAfterLast() and gives the same exception.

could it be because we haven't specified the concurrecy and type of the resultset?

martagle at 2007-6-29 9:41:59 > top of Java-index,Database Connectivity,Java Database Connectivity (JDBC)...
# 5
What line do you get the null exception on?
jschell at 2007-6-29 9:41:59 > top of Java-index,Database Connectivity,Java Database Connectivity (JDBC)...
# 6
in the line: if(rs.isLast())I don't have scrollable Resultset, is this method only for scrollable Resultset? In weblogic 5.1 I can't use scrollable Resultset, can I?
martagle at 2007-6-29 9:41:59 > top of Java-index,Database Connectivity,Java Database Connectivity (JDBC)...