Advertisement
Guest User

Untitled

a guest
Apr 30th, 2016
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.58 KB | None | 0 0
  1. //the first class code
  2. stmt = c.createStatement();
  3. JavaApplication8 dc = new JavaApplication8();
  4. String sql = "INSERT INTO records (start_date,hour,cell_name,Erlang,ErlangU,cell_type,freq_type) VALUES ( ?,?,?,?,?,?,? )";
  5. PreparedStatement pst = c.prepareStatement(sql);
  6. pst.setInt(1, dc.time());
  7. pst.setInt(2,heure );
  8. pst.setString(3, "fgf");
  9. pst.setFloat(4, 84/10);
  10. pst.setFloat(5,dc.Hourly_Traffic_900 );
  11. pst.setInt(6, 1);
  12. pst.setInt(7, 900);
  13.  
  14. stmt.execute(sql);
  15. stmt.close();
  16. c.commit();
  17. c.close();
  18. }} catch (ClassNotFoundException | SQLException e) {
  19. System.err.println( e.getClass().getName()+": "+ e.getMessage() );
  20. System.exit(0);
  21. }
  22. System.out.println("Records created successfully");}
  23.  
  24. //the jframe code
  25. Connection conn = new DBConnection().Connect();
  26. private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
  27. try {
  28.  
  29. float bsc = Float.parseFloat(jTextField1.getText());
  30. float cellsbsc = Float.parseFloat(jTextField2.getText());
  31. float days = Float.parseFloat(jTextField3.getText());
  32. int tot_dense =(int) (bsc*cellsbsc) ;
  33. JavaApplication8 dc = new JavaApplication8();
  34. Menu mm = new Menu();
  35. Connection c = null;
  36. Statement stmt = null;
  37.  
  38. Class.forName("org.postgresql.Driver");
  39. c = DriverManager.getConnection("jdbc:postgresql://localhost:5432/Records", "postgres", "21262050");
  40. c.setAutoCommit(false);
  41. System.out.println("Opened database successfully");
  42.  
  43. String sql = "INSERT INTO records (start_date,hour,cell_name,Erlang,ErlangU,cell_type,freq_type) VALUES ( ?,?,?,?,?,?,? )";
  44. PreparedStatement pst = c.prepareStatement(sql);
  45. if (mm.jRadioButton1.isSelected()&& mm.jButton1.isSelected()){
  46.  
  47. for(int i=1; i<tot_dense+1; i++)
  48. {
  49. for(int d=1; d<days+1; d++)
  50.  
  51. {
  52. dc.Day_900();
  53.  
  54. pst.setInt(1,dc.time() );
  55. pst.setInt(2,dc.heure );
  56. pst.setString(3, "fgf");
  57. pst.setFloat(4, 84/10);
  58. pst.setFloat(5,dc.Hourly_Traffic_900);
  59. pst.setInt(6, 1);
  60. pst.setInt(7, 900);
  61.  
  62. pst.execute();
  63. }
  64. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement