Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public void saveNozzleMeasureToDB (){
- final String JDBC_DRIVER = "com.mysql.jdbc.Driver";
- final String DB_URL = "jdbc:mysql://localhost:6033/";
- // Database credentials
- final String USER = "root";
- final String PASS = "";
- Connection conn = null;
- Statement stmt = null;
- try{
- Class.forName("com.mysql.jdbc.Driver");
- conn = DriverManager.getConnection(DB_URL, USER, PASS);
- stmt = conn.createStatement();
- String sql = "Use station";
- stmt.executeUpdate(sql);
- stmt = conn.createStatement();
- while (this.nozzleMeasuresBufferSize > 0){
- sql = "Insert into nozzlemeasures Values('" + DATE_FORMAT.format(DATE_FORMAT.parse(nozzleMeasuresList.get(0).data)) + "', " + nozzleMeasuresList.get(0).nozzleID + ", " + nozzleMeasuresList.get(0).tankID + ", " + 0 +
- ", " + nozzleMeasuresList.get(0).literCounter + ", " + nozzleMeasuresList.get(0).totalCounter + ", " + nozzleMeasuresList.get(0).status + ");";
- stmt.executeUpdate(sql);
- this.nozzleMeasuresList.remove(0);
- this.nozzleMeasuresBufferSize--;
- }
- }catch(SQLException se){
- se.printStackTrace();
- }catch(Exception e){
- e.printStackTrace();
- }finally{
- try{
- if(stmt!=null)
- stmt.close();
- }catch(SQLException se2){
- }
- try{
- if(conn!=null)
- conn.close();
- }catch(SQLException se){
- se.printStackTrace();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement