Statement interface:
The Statement interface provides methods to execute queries with the database. The statement interface is a factory of ResultSet i.e. it provides factory methods to get the object of ResultSet.
Methods of Statement interface:
>1. public ResultSet executeQuery(String sql): is used to execute SELECT query. It returns the object of ResultSet.
>2. public int executeUpdate(String sql): is used to execute specified query, it may be create, drop,insert, update, delete etc.
>3. public boolean execute(String sql): is used to execute queries that may return multiple results.
>4. public int[] executeBatch(): is used to execute batch of(multiple) at once commands.
ResultSet interface:
The object of ResultSet maintains a cursor pointing to a particular row of data. Initially, cursor points to before the first row.
Note: By default, ResultSet object can be moved forward only and it is not updatable.
But we can make this object to move forward and backward direction by passing either TYPE_SCROLL_INSENSITIVE or TYPE_SCROLL_SENSITIVE in createStatement(int,int)
method as well as we can make this object as updatable by:
Statement stmt = con.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_UPDATABLE);
Methods of ResultSet interface:
>1. public boolean next(): is used to move the cursor to the one row next from the current position.
>2. public boolean previous(): is used to move the cursor to the one row previous from the current position.
>3. public boolean first(): is used to move the cursor to the first row in result set object.
>4. public boolean last(): is used to move the cursor to the last row in result set object.
>5. public boolean absolute(int row): is used to move the cursor to the specified row number in the ResultSet object.
>6. public boolean relative(int row): is used to move the cursor to the relative row number in the ResultSet object, it may be positive or negative.
>7. public int getInt(int columnIndex): is used to return the data of specified column index of the current row as int.
>8. public int getInt(String columnName): is used to return the data of specified column name of the current row as int.
>9. public String getString(int columnIndex): is used to return the data of specified column index of the current row as String.
>10 public String getString(String columnName): is used to return the data of specified column name of the current row as String.
The Statement interface provides methods to execute queries with the database. The statement interface is a factory of ResultSet i.e. it provides factory methods to get the object of ResultSet.
Methods of Statement interface:
>1. public ResultSet executeQuery(String sql): is used to execute SELECT query. It returns the object of ResultSet.
>2. public int executeUpdate(String sql): is used to execute specified query, it may be create, drop,insert, update, delete etc.
>3. public boolean execute(String sql): is used to execute queries that may return multiple results.
>4. public int[] executeBatch(): is used to execute batch of(multiple) at once commands.
ResultSet interface:
The object of ResultSet maintains a cursor pointing to a particular row of data. Initially, cursor points to before the first row.
Note: By default, ResultSet object can be moved forward only and it is not updatable.
But we can make this object to move forward and backward direction by passing either TYPE_SCROLL_INSENSITIVE or TYPE_SCROLL_SENSITIVE in createStatement(int,int)
method as well as we can make this object as updatable by:
Statement stmt = con.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_UPDATABLE);
Methods of ResultSet interface:
>1. public boolean next(): is used to move the cursor to the one row next from the current position.
>2. public boolean previous(): is used to move the cursor to the one row previous from the current position.
>3. public boolean first(): is used to move the cursor to the first row in result set object.
>4. public boolean last(): is used to move the cursor to the last row in result set object.
>5. public boolean absolute(int row): is used to move the cursor to the specified row number in the ResultSet object.
>6. public boolean relative(int row): is used to move the cursor to the relative row number in the ResultSet object, it may be positive or negative.
>7. public int getInt(int columnIndex): is used to return the data of specified column index of the current row as int.
>8. public int getInt(String columnName): is used to return the data of specified column name of the current row as int.
>9. public String getString(int columnIndex): is used to return the data of specified column index of the current row as String.
>10 public String getString(String columnName): is used to return the data of specified column name of the current row as String.
No comments:
Post a Comment