Java 无法将数据插入数据库(insert语句中出现语法错误)
我得到的错误是 java.sql.SQLException:[Microsoft][ODBC Microsoft Access驱动程序]INSERT INTO语句中出现语法错误 有人帮我解决这个问题吗?谢谢这会有用的Java 无法将数据插入数据库(insert语句中出现语法错误),java,syntax,syntax-error,Java,Syntax,Syntax Error,我得到的错误是 java.sql.SQLException:[Microsoft][ODBC Microsoft Access驱动程序]INSERT INTO语句中出现语法错误 有人帮我解决这个问题吗?谢谢这会有用的 private void addCustomerActionPerformed( ActionEvent e ) { String Query; Query = "INSERT INTO Membership VALUES"+ "(' " +memberID_a.
private void addCustomerActionPerformed( ActionEvent e )
{
String Query;
Query = "INSERT INTO Membership VALUES"+ "(' " +memberID_a.getText() + " ' , ' " +memberName_a.getText() + " ' , ' " + icNo_a.getText() + " ', ' " + gender_a.getText() +" ' , '" + birthday_a.getText() +" ' , ' " + telephoneNo_a.getText() + " ',' " + mobileNo_a.getText() + " ' , ' " + email_a.getText() + " ' , ' " + address_a.getText() + " ' , " + postalCode_a.getText() + " ,' " + state_a.getText() + " ' , '" + country_a.getText() + " ' , " + memberPoint_a.getText() + ");";
try {
stmtInsert = conn.createStatement();
stmtInsert.executeUpdate(Query);
} catch(Exception ex){
JOptionPane.showMessageDialog(null,"ERROR"+ex.toString(),"ERROR",JOptionPane.ERROR_MESSAGE);
}
}
Query ="INSERT INTO Membership VALUES ( " +memberID_a.getText() + " , " +memberName_a.getText() + " , " + icNo_a.getText() + " , " + gender_a.getText() +" ," + birthday_a.getText() +"," + telephoneNo_a.getText() + " , " + mobileNo_a.getText() + " , " + email_a.getText() + " , " + address_a.getText() + " , " + postalCode_a.getText() + ", " + state_a.getText() + " ," + country_a.getText() + "," + memberPoint_a.getText() + ")";