String sql = " INSERT INTO `tblservice` (`ServiceID`,`accountID`, `Kind`, `Description`, `Price`, "
+ "`Quantity`, `Total`, `DateAndTime`) VALUES (NULL, ?, ?, ?, ?, ?, ?, ?)";
PreparedStatement pstm = conn.prepareStatement(sql);
pstm.setInt(1, this.accountID);
pstm.setString(2, "" + SelectionBox.getSelectedItem());
pstm.setString(3, desc);
pstm.setFloat(4, Float.parseFloat(PriceTF.getText()));
pstm.setFloat(5, Float.parseFloat(QuantityTF.getText()));
pstm.setFloat(6, this.getTotal());
pstm.setDate(7, dateAdded);
pstm.executeUpdate();
エラーJavaのSQLのINSERT preparedstatmentエラー
クエリ内代わりメイクNULLのcom.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: 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
どこに問題がありますか?文脈はどこですか?私たちはあなたに手伝ってくれるようもっと詳しい情報が必要です。 – leobelones
エラーメッセージはあなたに何をすべきか教えてくれました。あなたの質問は何ですか? – betseyb
私は現在、そのコードをトリガーするためにボタンを使用しています。ボタンを押すたびに、そのエラーが表示され、何も操作トリガーはデータが挿入されていないことを意味します。テーブルに新しいデータを追加するべきではないはずですが、動作していません。 – meltits