我必须在JForm的HQL中创建插入参数化查询。
我已经在MySQL中创建了它,但是HQL出现了问题...
private void jBtn_submitActionPerformed(java.awt.event.ActionEvent evt) {
String query = "insert into schema.table values(?,?,?,?,?)";
try
{
pst = kon.prepareStatement(query);
pst.setString(1, null);
pst.setString(2, jTxtF_name.getText());
pst.setString(3, jTxtF_year.getText());
pst.setString(4, jTxtF_adres.getText());
pst.setString(5, jTxtF_income.getText());
pst.execute();
pst.close();
JOptionPane.showMessageDialog(null, "successfully import");
}
catch(Exception ex)
{
JOptionPane.showMessageDialog(null, ex);
}
jTxtF_name.setText("");
jTxtF_year.setText("");
jTxtF_adres.setText("");
jTxtF_income.setText("");
}