1064 Error
843854Mar 26 2005 — edited Mar 26 2005Hello guys. I am writing, well trying, to write, an application in Java that uses MySQL. When I run my application to enter a new record I get the following error:
SQLException: You have an error in your SQL syntax; check the manual that corres
ponds to your MySQL server version for the right syntax to use near '9,'S1,'[Lja
va.lang.Object;@5e3974,'null,'null,'null,'26-03-2005,'0900,'1300,'nul' at line 1
SQLState: 42000
VendorError: 1064
I think the problem is in the following Java code:
class AddBooking implements ActionListener{
public void actionPerformed (ActionEvent event){
try {
Statement stmt = con.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_UPDATABLE);
// Prepare a statement to insert a record
String sql = "INSERT INTO tblBookings " +
"(DateBookingMade,CustomerID,RoomName,Single,Daily,Weekly,Monthly,DateBookedFor, TimeFrom, TimeTo, TablesChairs, Projector, FlipCharts, SoundsSystem, Bar)" +
"VALUES (" +
"'" + bookMadeDateButton.getText() + "," +
"'" + customerIDB.getText() + "," +
"'" + roomNameBox.getSelectedItem() + "," +
"'" + single.getSelectedObjects() + "," +
"'" + daily.getSelectedObjects() + "," +
"'" + weekly.getSelectedObjects() + "," +
"'" + monthly.getSelectedObjects() + "," +
"'" + bookingDateButton.getText() + "," +
"'" + timeFrom.getSelectedItem() + "," +
"'" + timeTo.getSelectedItem() + "," +
"'" + tablesChairs.getSelectedObjects() + "," +
"'" + projector.getSelectedObjects() + "," +
"'" + flipChart.getSelectedObjects() + "," +
"'" + soundSystem.getSelectedObjects() + "," +
"'" + bar.getSelectedObjects() +")";
// Execute the insert statement
stmt.executeUpdate(sql);
} catch (SQLException e) {
System.out.println("SQLException: " + e.getMessage());
System.out.println("SQLState: " + e.getSQLState());
System.out.println("VendorError: " + e.getErrorCode());
}
}
}
Any ideas would be a great help. Thanks so much.