private void insertData(SymptomsData data) { Connection connection = null; Statement statement = null; try { connection = DatabaseHelper.getConnection(); statement = connection.createStatement(); String query = "Insert into medicine_table values(" + data.getId() + ", '" + data.getSymptoms() + "', '" + data.getMedicines() + "')"; statement.executeUpdate(query); } catch (SQLException e) { e.printStackTrace(); } finally { if (connection != null) { try { connection.close(); } catch (SQLException e) { e.printStackTrace(); System.out.println(e); } } } }
private void jButton1ActionPerformed( java.awt.event.ActionEvent evt) { // GEN-FIRST:event_jButton1ActionPerformed // TODO add your handling code here: dispose(); success_patdiagnose sp = new success_patdiagnose(); sp.setVisible(true); SymptomsData data = new SymptomsData(); data.setId(Integer.parseInt(id.getText())); data.setSymptoms(symptoms.getText()); data.setMedicines(medicine.getText()); insertData(data); } // GEN-LAST:event_jButton1ActionPerformed