sql - Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException -
my code stopped working, , errors occur
exception in thread "awt-eventqueue-0" java.lang.nullpointerexception @ ultimate_library.unified.showall(unified.java:47) @ ultimate_library.unified.<init>(unified.java:34) @ ultimate_library.unified$8.run(unified.java:653)
the code below doesnt have error, dont understand not working, works sends error "java.sql.sqltransactionrollbackexception: lock not obtained within time requested"
public unified() { initcomponents(); doconnect(); showall(); doconnect2(); showall2(); } void showall(){ try{ rss = stmt.executequery("select * accounts"); while(rss.next()) { string name = rss.getstring("name"); string email = rss.getstring("email"); string bdays = rss.getstring("bday"); loginmodel.addrow(new object[]{name, email, bdays}); } }catch(sqlexception err){ system.out.println(err); } } public static void main(string args[]) { java.awt.eventqueue.invokelater(new runnable() { public void run() { new unified().setvisible(true); } }); }
i found mistake, instead of rss, replaced rs2.
void showall(){ try{ rs2 = stmt.executequery("select * accounts"); while(rs2.next()) { string named = rs2.getstring("name"); string emailss = rs2.getstring("email"); string bdayss = rs2.getstring("birthday"); loginmodel.addrow(new object[]{named, emailss, bdayss}); } }catch(sqlexception err){ system.out.println(err); } }
java sql jdbc
No comments:
Post a Comment