Reputation: 79
Iam new to java and trying to develop small swing app, I have Inquiry model class which containing getters and setters and constructions and also iam getting input by user in JFrame.
Im getting this error java.sql.SQLException: At least one parameter to the current statement is uninitialized
" when run this 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 INTO INQUIRY (IN_ID,IN_TITLE,IN_MSG,IN_DATE)VALUES(?,?,?,?)";
PreparedStatement pr = con.prepareStatement(sq);
pr.executeUpdate();
} catch (SQLException ex) { ex.printStackTrace();
}
}
}
can some one please help me to solve this.
Upvotes: 0
Views: 43
Reputation: 44854
You are not setting any value in
String sq = "INSERT INTO INQUIRY (IN_ID,IN_TITLE,IN_MSG,IN_DATE)VALUES(?,?,?,?)";
PreparedStatement pr = con.prepareStatement(sq);
// set values here
pr.executeUpdate();
Upvotes: 2