i having weird problem iterator don't understand. iterator being used in loggedpreparedstatement every , (about 20 of 200) throws error:
sqlexception in executequery, errorcode: 0, sql state: 07001, message: no value specified parameter 1 while executing statement: com.mysql.jdbc.preparedstatement@11fffa73: select ac.id ac left join pa on pa.id = ac.adspace_id pa.adspace_id in (** not specified **)
this how create iterator:
private iterator< integer > adspacesid = null; public arraylist<integer> getids(int inadspaceid) { if (inadspaceid <= 0) return new arraylist<integer>(); arraylist<integer> templist = new arraylist<integer>(); templist.add(new integer(inadspaceid)); adspacesid = templist.listiterator(); num = templist.size(); activeonly = false; if (adspacesid != null && adspacesid.hasnext() && num > 0) { executequery(); } return result; }
so add int temp arraylist , turn iterator, use iterator in query so:
loggedpreparedstatement statement = new loggedpreparedstatement(thequery.tostring()); statement.setint(1, adspacesid);
so first guess be, no entries in iterator, how pass check of adspacesid.hasnext() then?
the value of num 1, there entry in templist , assume in iterator.
little welcome :)
arraylist<integer> list = new arraylist<integer>(); list.add(1); list.add(2); list.add(3); iterator<integer> = list.listiterator(); system.out.println("first element : " + it.next());
i guess have call next() elements first one. don't see have done here. , if preparedstatement, don't see have added parameter before executing executequery(), , suggest use listiterator interface instead iterator here..
Comments
Post a Comment