0
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());
}
}
它顯示一個錯誤,是mising(在「String Query = ...」中)。但我無法解決這個問題。 請幫忙。 我在netbeans中做這個。半冒號缺少錯誤
非常感謝.. !!
使用參數爲您的查詢它將使格式化查詢更容易 – Sybren
感謝您的幫助 – klbm9999