0 کاربر و 1 مهمان درحال مشاهده موضوع.
try { Class.forName("com.mysql.jdbc.Driver"); String animalName = ""; String animalType = ""; int animalAge = 0; int caseNumber = 0; animalName = animalsNameTXT.getText(); animalType = (String) animalsTypeCOMBO.getSelectedItem(); animalAge = Integer.parseInt(animalsAgeTXT.getText()); caseNumber = Integer.parseInt(caseNumbersTXT.getText()); Connection conn = null; Statement stm = null; String sql = null; conn = DriverManager.getConnection(URL, USER, PASS); stm = conn.createStatement(); sql = "INSERT INTO ANIMALS(ANIMALNAME,ANIMALTYPE,ANIMALAGE,CASENUMBER ) VALUES('"+animalName+"','"+animalType+"',"+animalA ge+","+caseNumber+")"; animalsNameTXT.setText(""); animalsAgeTXT.setText(""); caseNumbersTXT.setText(""); stm.executeUpdate(sql); } catch (SQLException e) { JOptionPane.showMessageDialog(null, e); } catch (ClassNotFoundException ex) { Logger.getLogger(Animals.class.getName()).log(Leve l.SEVERE, null, ex); }