Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Getting SQL error SQL State S1009

I'm trying to insert values into a table (inquiry) the first value is of type Date , and I'm getting an SQL error SQL State S1009. what is the proper way to convert the date , what am I doing wrong?

String sqlStatement = "INSERT INTO inquiry (INQUIRY_DATE,INQUIRY_NOTE,INQUIRER_ID,PROGRAM_ID,CLASS_ID,CORPORATE_ID)\n"
                + "VALUES (?,?,?,?);";

        ps = con.prepareStatement(sqlStatement);
        java.sql.Date sDate = new java.sql.Date(inquiry.getInquiryDate().getTime());

        int parameterIndex = 1;
        ps.setDate(parameterIndex, sDate);
        ps.setString(parameterIndex++, inquiry.getInquiryNote());
        ps.setInt(parameterIndex++, inquiry.getInquirer().getInquirerID());
        ps.setInt(parameterIndex++, inquiry.getProgramID());
        ps.setInt(parameterIndex++, inquiry.getClassProgramID());
        ps.setInt(parameterIndex++, 1);
like image 605
Ahmad Abu Baker Avatar asked Oct 21 '25 04:10

Ahmad Abu Baker


1 Answers

sqlStatement = "INSERT INTO inquiry (INQUIRY_DATE,INQUIRY_NOTE,INQUIRER_ID,PROGRAM_ID,CLASS_ID,CORPORATE_ID)\n"
                + "VALUES (?,?,?,?);";

The parameterized query doesn't have enough ?, you queried 6 columns with 2 ? missing, it should be VALUES (?,?,?,?,?,?); ? are used for holding the places for your setXXX() column values

like image 168
Haifeng Zhang Avatar answered Oct 23 '25 19:10

Haifeng Zhang



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!