Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //the first class code
- stmt = c.createStatement();
- JavaApplication8 dc = new JavaApplication8();
- String sql = "INSERT INTO records (start_date,hour,cell_name,Erlang,ErlangU,cell_type,freq_type) VALUES ( ?,?,?,?,?,?,? )";
- PreparedStatement pst = c.prepareStatement(sql);
- pst.setInt(1, dc.time());
- pst.setInt(2,heure );
- pst.setString(3, "fgf");
- pst.setFloat(4, 84/10);
- pst.setFloat(5,dc.Hourly_Traffic_900 );
- pst.setInt(6, 1);
- pst.setInt(7, 900);
- stmt.execute(sql);
- stmt.close();
- c.commit();
- c.close();
- }} catch (ClassNotFoundException | SQLException e) {
- System.err.println( e.getClass().getName()+": "+ e.getMessage() );
- System.exit(0);
- }
- System.out.println("Records created successfully");}
- //the jframe code
- Connection conn = new DBConnection().Connect();
- private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
- try {
- float bsc = Float.parseFloat(jTextField1.getText());
- float cellsbsc = Float.parseFloat(jTextField2.getText());
- float days = Float.parseFloat(jTextField3.getText());
- int tot_dense =(int) (bsc*cellsbsc) ;
- JavaApplication8 dc = new JavaApplication8();
- Menu mm = new Menu();
- Connection c = null;
- Statement stmt = null;
- Class.forName("org.postgresql.Driver");
- c = DriverManager.getConnection("jdbc:postgresql://localhost:5432/Records", "postgres", "21262050");
- c.setAutoCommit(false);
- System.out.println("Opened database successfully");
- String sql = "INSERT INTO records (start_date,hour,cell_name,Erlang,ErlangU,cell_type,freq_type) VALUES ( ?,?,?,?,?,?,? )";
- PreparedStatement pst = c.prepareStatement(sql);
- if (mm.jRadioButton1.isSelected()&& mm.jButton1.isSelected()){
- for(int i=1; i<tot_dense+1; i++)
- {
- for(int d=1; d<days+1; d++)
- {
- dc.Day_900();
- pst.setInt(1,dc.time() );
- pst.setInt(2,dc.heure );
- pst.setString(3, "fgf");
- pst.setFloat(4, 84/10);
- pst.setFloat(5,dc.Hourly_Traffic_900);
- pst.setInt(6, 1);
- pst.setInt(7, 900);
- pst.execute();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement