Advertisement
Guest User

Untitled

a guest
Jun 27th, 2019
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.65 KB | None | 0 0
  1. public void showTable(){
  2. try{
  3.  
  4. how.res = how.stat.executeQuery("select * from students order by name ASC limit 100");
  5.  
  6. while(how.res.next()){
  7. String id = how.res.getString(1);
  8. String name = how.res.getString(2);
  9. String contact = how.res.getString(3);
  10.  
  11. Object[] content = {id,name,contact};
  12. DefaultTableModel model = (DefaultTableModel)jTable1.getModel();
  13. model.addRow(content);
  14.  
  15. }
  16. }catch (Exception e){
  17.  
  18. }
  19. }
  20.  
  21. private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) {
  22. // TODO add your handling code here:
  23. try{
  24. numClick+=100;
  25. how.res = how.stat.executeQuery("select * from students offset"+numClick+"");
  26.  
  27. while(how.res.next()){
  28. String id = how.res.getString(1);
  29. String name = how.res.getString(2);
  30. String contact = how.res.getString(3);
  31.  
  32. Object[] content = {id,name,contact};
  33. DefaultTableModel model = (DefaultTableModel)jTable1.getModel();
  34. model.addRow(content);
  35. }
  36. }catch (Exception e){
  37.  
  38. }
  39. }
  40.  
  41. public class JoinConnection {
  42.  
  43. public Connection con;
  44. public Statement stat;
  45. public ResultSet res;
  46.  
  47. public JoinConnection(){
  48.  
  49. systemConnection();
  50. }
  51.  
  52. public void systemConnection(){
  53. try{
  54. Class.forName("com.mysql.jdbc.Driver");
  55. con =(com.mysql.jdbc.Connection) DriverManager.getConnection("jdbc:mysql://localhost:3306/library","root","");
  56. stat = (Statement) con.createStatement();
  57. }catch(ClassNotFoundException | SQLException e){System.out.println(e);}
  58. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement