You are on page 1of 1

try{

Class.forName("com.mysql.jdbc.Driver");
Connection
conn=DriverManager.getConnection("jdbc:mysql://localhost:3307/project","chaithra","
root123");

String query="insert into project.bill values(?,?,?,?,?,?,?,?,?,?)";


PreparedStatement stmt=conn.prepareStatement(query);
stmt.setString(1,jTextField1.getText());
stmt.setString(5,jTextField2.getText());
stmt.setString(6,jTextField3.getText());
stmt.setString(2,jTextField4.getText());
stmt.setString(8,jTextField5.getText());
stmt.setString(3,jTextField6.getText());
stmt.setString(9,jTextField7.getText());
stmt.setString(10,jTextField8.getText());
stmt.setString(4,jTextField9.getText());
stmt.setString(7,jTextField10.getText());
stmt.executeUpdate();
JOptionPane.showMessageDialog(null," RECORD INSERTED SUCCESSFULY");
conn.close();

}
catch(Exception e)
{
JOptionPane.showMessageDialog(null,e);
}

You might also like