i writing very simple query. cannot find error. here code:
con = dbconnect.connect(); try { preparedstatement query = (preparedstatement) con.preparestatement("select * accounts iban=?"); query.setstring(1, iban); resultset result = (resultset) query.executequery(); double oldbalance; } catch (sqlexception e) { system.out.println(e); }
i sure name of table accounts, , there exists column of type varchar called iban. debugged , sure query.setstring(1, iban);
line sets iban correctly.
but when comes line resultset result = (resultset) query.executequery();
jumps last line, consists of "}". not enter catch block , cannot see problem.
what wrong here can please tell me?
thanks
edit: looks query executes succesfully. after executequery line do:
double oldbalance=result.getdouble("iban");
and gives me error:
java.sql.sqlexception: before start of result set
can tell me problem here?
when debug code, once you're @ resultset result = (resultset) query.executequery();
line, since nothing else after done in try
block, if go next step, jump end of block.
so query might working fine, need in block since resultset
assigned within block.
edit : check answer other problem.
Comments
Post a Comment