File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes JDBC and Relational Databases and the fly likes using a ResultSet with setxxx Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC and Relational Databases
Bookmark "using a ResultSet with setxxx" Watch "using a ResultSet with setxxx" New topic

using a ResultSet with setxxx

myriah wind

Joined: Mar 04, 2005
Posts: 14
i'm trying to persist jdbc data from a ResultSet and have this for a problem:
class Collector extends Thread {
DateWriter writer = new DateWriter ();
String selectQuery = "SELECT * from xxxData";
+ "WHERE "
+ "serv_prov_type_id == 'BC'";
Statement stmt = con.createStatement();
rset = stmt.executeQuery(selectQuery);

//writer is an instance of DateWriter
// DateWriter is the class that starts Colector

int col = 0;
while( {

uid = rset.getInt(1);
pers_id = rset.getInt(2);
serv_prov_type_id = rset.getInt(3);
writer.setPers_id(rows, uid, pers_id); // error
name_last = rset.getString(4);
name_1st = rset.getString(5);
name_cmmn = rset.getString(6);
sex = rset.getString(7);
born_date = rset.getDate(8);
writer.getMessageDateTime(); //this works

the error is thrown only within the loop.
StringBuffer.<init>(String) line: 145 [local variables unavailable]

does anyone know what's going on here??? better yet how to make it work?
Shailesh Chandra
Ranch Hand

Joined: Aug 13, 2004
Posts: 1082


writer.setPers_id(rows, uid, pers_id); // error

If this line is giving error then possibily the is a problem in setPers_id method in DateWriter class.

can you provide code of same


Gravitation cannot be held responsible for people falling in love ~ Albert Einstein
Adeel Ansari
Ranch Hand

Joined: Aug 15, 2004
Posts: 2874
Please follow the naming convention

writer.setPers_id(rows, uid, pers_id);

should be like

writer.setPersId(rows, uId, persId);

And can you please print the whole stack trace?
myriah wind

Joined: Mar 04, 2005
Posts: 14
public void setPers_id(int rows, int uid, String persId); {
natPersId[index] = "XX:"+uid+":"+persId+":08";
is the method.
I'm getting StringBuffer.<init>(String) line: 145 [local variables unavailable] message out of WebSphere Studio's debugging facility.
just running it produces a java.lang.NullPointerException

it behaves the same even if I hard cose values into
setPers_id(123, 456, "rnp");
I agree. Here's the link:
subject: using a ResultSet with setxxx
jQuery in Action, 3rd edition