Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private void jinsertActionPerformed(java.awt.event.ActionEvent evt) {
- try {
- String id=jid.getText();
- String name=jname.getText();
- String addr=jaddr.getText();
- Class.forName("com.mysql.jdbc.Driver");// TODO add your handling code here:
- try {
- Connection con=DriverManager.getConnection("jdbc:mysql://localhost:3306/b1","root","root");
- Statement stmt=con.createStatement();
- String q="insert into t1(id,name,addr) values("+id+",'"+name+"','"+addr+"');";
- stmt.executeUpdate(q);
- JOptionPane.showMessageDialog(null, "Data inserted");
- } catch (SQLException ex) {
- Logger.getLogger(sqlf.class.getName()).log(Level.SEVERE, null, ex);
- }
- } catch (ClassNotFoundException ex) {
- Logger.getLogger(sqlf.class.getName()).log(Level.SEVERE, null, ex);
- }
- }
Add Comment
Please, Sign In to add comment