Saturday, 25 April 2020

SE - 74 - Statement and ResultSet

Statement and Resultset are used in JDBC connections to run queries and store results. The results are then used further in the program.


JDBC Statement:

Statement is an interface. It provides some methods through which we can submit SQL queries to the database. It will be implemented by driver implementation providers. createStatement() method on Connection object will return Statement object.


JDBC ResultSet:

ResultSet also an interface and is used to retrieve SQL select query results. A ResultSet object maintains a cursor pointing to its current row of data. Initially the cursor is positioned before the first row. The next method moves the cursor to the next row, and because it returns false when there are no more rows in the ResultSet object, it can be used in a while loop to iterate through the result set. It provides getXXX() methods to get data from each iteration. Here XXX represents datatypes.

No comments:

Post a Comment