Question: String sql; private void SaveActionPerformed ( java . awt.event.ActionEvent evt ) { / / TODO add your handling code here: String brand = Brand.getText (

String sql;
private void SaveActionPerformed(java.awt.event.ActionEvent evt){
// TODO add your handling code here:
String brand = Brand.getText();
String description = Description.getText();
int idNumber = Integer.parseInt(IDNumber.getText());
String name = Name.getText();
double price = Double.parseDouble(Price.getText());
int quantity = Integer.parseInt(Quanity.getText());
String shoeType = ShoeType.getText();
final String DB_URL ="jdbc:derby://localhost:1527/TheRunningCompanyDB";
try {
java.sql.Connection conn = DriverManager.getConnection(DB_URL, "app", "app");
java.sql.Statement statement = conn.createStatement();
PreparedStatement pstmt = conn.prepareStatement();
sql = "Insert into Products values(idNumber, name, description, price, quanity, shoeType, brand) values (?,?,?,?,?,?,?)";
try (PreparedStatement pstmt = conn.prepareStatement(sql)){
pstmt.setInt(1, idNumber);
pstmt.setString(2, name);
pstmt.setString(3, description);
pstmt.setDouble(4, price);
pstmt.setInt(5, quantity);
pstmt.setString(6, shoeType);
pstmt.setString(7, brand);
pstmt.executeUpdate();
}
} catch (SQLException ex){
System.out.println(ex.getMessage());
}
}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!