Code example for Statement

Methods: executeUpdate

0
            Connection con;
            try { 
                con = DriverManager.getConnection(connectionUrl, userName, password);
                // Step 3:  Create a statement where the SQL statement will be provided 
                Statement stmt = con.createStatement();
                stmt.executeUpdate("create table accounts(id INTEGER GENERATED BY DEFAULT AS IDENTITY(START WITH 100) PRIMARY KEY, name varchar(50), balance decimal(15,2))");
                stmt.executeUpdate("INSERT INTO accounts (name, balance) values('George', 100)");
                stmt.executeUpdate("INSERT INTO accounts (name, balance) values('Paul', 100)");
                stmt.executeUpdate("INSERT INTO accounts (name, balance) values('Ringo', 1000)");
            } catch (SQLException e) {
                // TODO Auto-generated catch block 
                e.printStackTrace();
            } 
 
        } 
	 
}