0

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.

1
  • Even if invoked from a Swing GUI, the problem description and code snippet suggests it has nothing to do with Swing, so don't add the Swing tag! Commented Sep 13, 2016 at 4:31

1 Answer 1

2

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();
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.