MySQL Forums
Forum List  »  Connector/JDBC and Java

error on insert in mysql table
Posted by: paolo balz
Date: November 08, 2017 05:28PM

Hi all,
when I try to insert a row in mysql table I've got this error:

SQLException: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '?,?,?,?,?,?,?,?,?,?,?,?,?,?)' at line 1
SQLState: 42000
VendorError: 1064

Can someone help me?

this is thecode:

String sql2 = "INSERT INTO quote "
+ "(codice, giorno, tipo, data_ult, str, scad, pr, de, le, va, va_perc, vo, op, voli) VALUES"
+ "(?,?,?,?,?,?,?,?,?,?,?,?,?,?)";

preparedStatement = (PreparedStatement) conn.prepareStatement(sql2);

preparedStatement.setString(1, linea[0].toString());
preparedStatement.setString(2, linea[1].toString());
preparedStatement.setString(3, linea[2].toString());
preparedStatement.setString(4, linea[3].toString());
preparedStatement.setFloat(5, Float.parseFloat(linea[4]));
preparedStatement.setString(6, linea[5].toString());
preparedStatement.setFloat(7, Float.parseFloat(linea[6]));
preparedStatement.setFloat(8, Float.parseFloat(linea[7]));
preparedStatement.setFloat(9, Float.parseFloat(linea[8]));
preparedStatement.setFloat(10, Float.parseFloat(linea[9]));
preparedStatement.setString(11, linea[10].toString());
preparedStatement.setInt(12, Integer.parseInt(linea[11]));
preparedStatement.setInt(13, Integer.parseInt(linea[12]));
preparedStatement.setFloat(14, Float.parseFloat(linea[13]));

preparedStatement.executeUpdate(sql2);
if(preparedStatement!=null){
preparedStatement.close();
System.out.println("Success.");
}

Thanks

Options: ReplyQuote


Subject
Written By
Posted
error on insert in mysql table
November 08, 2017 05:28PM


Sorry, only registered users may post in this forum.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.