• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
Bartenders:
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

using a ResultSet with setxxx

 
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
writer.setUniqueMessageChid(String.valueOf(now));
writer.setMessageDateTime(date);

int col = 0;
while(rset.next()) {
rows++;

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?
 
Ranch Hand
Posts: 1087
Oracle Spring Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Myriah

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

Shailesh
 
Ranch Hand
Posts: 2874
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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");
 
What's wrong? Where are you going? Stop! Read this tiny ad:
the value of filler advertising in 2020
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic