private void add_computer_buttonActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
try{
String url ="jdbc:derby://localhost:1527/Computer_Inventory";
String usr ="admin1";
String pass ="password";
Connection con = DriverManager.getConnection(url,usr,pass);
Statement st = con.createStatement();
String Query;
Query = "INSERT INTO INVENTORY (EMP_NAME, DESIGNATION, ID, DEPARTMENT, COM_COMPANY, COM_MODEL, COM_SR_NO, COM_EXSER_TAG, PRIN_PRESENT, PRIN_COMPANY, PRIN_MODEL, PRIN_EXSER_TAG, PRIN_SR_NO, CARTRIDGE_MODEL, COMMISSION_DAY, COMMISSION_MONTH, COMMISSION_YEAR) VALUES ('"+emp_name_txt.getText()+"' , '"+designation_txt.getText()+"' , '"+emp_id_txt.getText()+"' , '"+emp_dept_txt.getText()+"' , '"+comp_company_txt.getText()+"' , '"+comp_model_txt.getText()+"' , '"+comp_serial_txt.getText()+"' , '"+comp_exsertag_txt.getText()+"' , '"+prin_present_combo.getSelectedItem()+"' , '"+prin_company_txt.getText()+"' , '"+prin_model_txt.getText()+"' , '"+prin_exsertag_txt.getText()+"' , '"prin_serial_txt.getText()"' , '"+prin_cartridge_txt.getText()+"' , '"+date_combo.getSelectedItem()+"' , '"+month_combo.getSelectedItem()+"' , '"+year_combo.getSelectedItem()+"')";
JOptionPane.showMessageDialog(null, "Computer added to database");
}
catch(SQLException e){
JOptionPane.showMessageDialog(null, e.toString());
}
}
it shows an error that a ; is mising (in "String Query = ..."). But i am not able to sort this out. please help. I am making this in netbeans.
Thanks a lot..!!
As said in the comment by Sybren, you should use parameters for your query. Or you can also use String.format() to make this look better.
For the problem, search for
prin_serial_txt.getText()
and do a proper concatination there in your Query string.