To insert data in database using stored procedure in java.
private void CreateuserActionPerformed( java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
String customerName=jTextField12. getText();
String contactPerson=jTextField13. getText();
String Address=jTextField14.getText() ;
String City=jTextField15.getText();
String phoneNo=jTextField16.getText() ;
String faxNo=jTextField17.getText();
String mobileNo=jTextField18.getText( );
String emailId=jTextField19.getText() ;
String openingDebitBalance= jTextField2.getText();
String openingCreditBalance= jTextField20.getText();
String customerStatus=jTextField21. getText();
// String Saluation = jComboBox2.getSelectedItem(). toString();
try {
Connection conn=DBConnection. getDBConnection();
String query = "{call USP_ADD_CUSTOMER(?,?,?,?,?,?,? ,?,?,?)}";
CallableStatement cs = conn.prepareCall(query);
cs.setString(1,customerName);
cs.setString(2, contactPerson);
cs.setString(3, Address);
cs.setString(4, City);
cs.setString(5, phoneNo);
cs.setString(6, faxNo);
cs.setString(7, mobileNo);
cs.setString(8, emailId);
cs.setString(9, openingDebitBalance);
cs.setString(10, openingCreditBalance);
} catch (Exception e) {
e.printStackTrace();
// e.getMessage().toString();
}
}
No comments:
Post a Comment