This week's book giveaways are in the AI and JavaScript forums.
We're giving away four copies each of GANs in Action and WebAssembly in Action and have the authors on-line!
See this thread and this one for details.
Win a copy of GANs in ActionE this week in the AI forum
or WebAssembly in Action in the JavaScript forum!
  • 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
  • Bear Bibeault
  • Paul Clapham
  • Jeanne Boyarsky
  • Knute Snortum
Sheriffs:
  • Liutauras Vilda
  • Tim Cooke
  • Junilu Lacar
Saloon Keepers:
  • Ron McLeod
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Joe Ess
  • salvin francis
  • fred rosenberger

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");
 
That which doesn't kill us makes us stronger. I think a piece of pie wouldn't kill me. Tiny ad:
Java file APIs (DOC, XLS, PDF, and many more)
https://products.aspose.com/total/java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!