-2

I want to know about the implementation of

ResultSet rs=cn.executeQuery();
rs.next();

now where next is implemented.

I can not find where my ResultSet interface next() method implementation available in JDBC.

Maroun
  • 94,125
  • 30
  • 188
  • 241

4 Answers4

1

All database should support common operations of executing a query, traverse through the resultset, reading each column in a result, getting a connection,closing a connection ...etc.

So these standard operations are made as interface methods by Java. ow the vendors who provide database drivers, implement this interface and hence they have to write their own implementation for each methods.

so you can find implementation in a jar that you are using for database connection like sqljdbc, odbc etc.

shreyansh jogi
  • 2,082
  • 12
  • 20
1

ResultSet is a interface, It doesn't have any method implementation.

You need to see the implemented classes.

That implementation classes are JRE specific.

Community
  • 1
  • 1
Suresh Atta
  • 120,458
  • 37
  • 198
  • 307
1

ResultSet is an interface for supporting all the common database operations.

Different vendors such as Oracle, MySQL, HSQLDB all have implemented their own drivers which contain the actual vendor specific implementation.

These drivers are present in the form of jars which you have to add to your project classpath to be able to communicate with that vendor specific database.

Narendra Pathai
  • 41,187
  • 18
  • 82
  • 120
0

your question is not clear but i give some code try this :

 String query = "SELECT * from sss;
    ResultSet rs = stmt.executeQuery(query);

    while(rs.next())
    {
            String xx = rs.getString("x");
    }
Mr.G
  • 3,413
  • 2
  • 16
  • 20