Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- try{
- con = DriverManager.getConnection("jdbc:mysql://localhost:3306/sampledata","root","");
- String sql= "SELECT * FROM studentinfo";
- pst=con.prepareStatement(sql);
- rs=pst.executeQuery();
- jTable1.setModel(DbUtils.resultSetToTableModel(rs));
- }
- catch(Exception ex){
- JOptionPane.showMessageDialog(null, ex);
- }
- try {
- // TODO add your handling code here:
- String sql = "INSERT INTO studentinfo" + "(FIRSTNAME, LASTNAME, GRADELEVEL, SECTION, CN)" + "VALUES (?,?,?,?,?)";
- con = DriverManager.getConnection("jdbc:mysql://localhost:3306/sampledata","root","");
- pst = con.prepareStatement (sql);
- pst.setString(1, textfn.getText());
- pst.setString(2, textln.getText());
- pst.setString(3, textgl.getText());
- pst.setString(4, textsection.getText());
- pst.setString(5, textcn.getText());
- pst.executeUpdate();
- JOptionPane.showMessageDialog(this, "Added Successfully");
- } catch (SQLException ex) {
- Logger.getLogger(StudentRegistry.class.getName()).log(Level.SEVERE, null, ex);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement