Insert_Data1.htm
 
 
pgAdmin : views

Code :
 
 public static void main(String args[]) {
        // TODO code application logic here
        System.out.println("main block executing ");
        Connection con = null;  Statement st = null;
        // connecting to db
        String url = "jdbc:postgresql://localhost/pgsdemo1";
        String user = "manas237";  String password = "pwmanas237";
        System.out.println("host user and password ---passd through ");
        try {
            con = DriverManager.getConnection(url, user, password);
           con.setAutoCommit(false);
           System.out.println("Data Base connected ");
           // 1
            String sql = "INSERT INTO DEPT5 VALUES"
                    + " (10,'ACCOUNTING','NEW YORK');"; 
             st = con.createStatement();
             System.out.println("row 1 added ") ;
           st.executeUpdate(sql);
           //2
           sql = "INSERT INTO DEPT5 VALUES"
                    + " (20,'RESEARCH','DALLAS');"; 
             st = con.createStatement();
             System.out.println("row 1 added ") ;
           st.executeUpdate(sql);
           // 3
            sql = "INSERT INTO DEPT5 VALUES"
                    + " (30,'SALES','CHICAGO');"; 
             st = con.createStatement();
             System.out.println("row 1 added ") ;
           st.executeUpdate(sql);
           // 4
            sql = "INSERT INTO DEPT5 VALUES"
                    + " (40,'OPERATIONS','BOSTON');"; 
             st = con.createStatement();
             System.out.println("row 1 added ") ;
           st.executeUpdate(sql);
           //
           st.close(); con.commit();con.close();
       
        } catch (SQLException ex) {
            Logger lgr = Logger.getLogger(Template1.class.getName());
            lgr.log(Level.SEVERE, ex.getMessage(), ex);

        } finally {
            try {
               
                if (st != null) {
                    st.close();
                    System.out.println("Statement createStament... closed");
                }
                if (con != null) {
                    con.close();
                    System.out.println("DB connection... closed");
                }
                     System.out.println("finally block executing ");
            } catch (SQLException ex) {
                Logger lgr = Logger.getLogger(Template1.class.getName());
                lgr.log(Level.WARNING, ex.getMessage(), ex);
            }
        }
        
        
        // main block ends here
   }		
		
		
Runt time confirmation