java - SQLException related to insert database values using ArrayList -
iam new java , trying develop small swing app, have inquiry model class containing getters , setters , constructions , iam getting input user in jframe.
im getting error java.sql.sqlexception: @ least 1 parameter current statement uninitialized
" when run code.
public class makeandreply_inquiry { string in_id=null; string in_title=null; string in_msg=null; date in_date; connection con; public void insertinquirytodb(arraylist<inquiry> arrlist){ try { dateformat dateformat = new simpledateformat("yyyy/mm/dd hh:mm:ss"); in_date = new date(); system.out.println(dateformat.format(in_date)); //2014/08/06 15:59:48 iterator<inquiry> iter = arrlist.iterator(); while(iter.hasnext()) { inquiry inq = iter.next(); in_id=inq.getin_id(); in_title=inq.getin_title(); in_msg=inq.getin_msg(); } con = new dbconnector().connect(); system.out.println("nside insert inq method "+in_id +in_title+in_msg); string sq = "insert inquiry (in_id,in_title,in_msg,in_date)values(?,?,?,?)"; preparedstatement pr = con.preparestatement(sq); pr.executeupdate(); } catch (sqlexception ex) { ex.printstacktrace(); } } }
can 1 please me solve this.
you not setting value in
string sq = "insert inquiry (in_id,in_title,in_msg,in_date)values(?,?,?,?)"; preparedstatement pr = con.preparestatement(sq); // set values here pr.executeupdate();
Comments
Post a Comment