javajdbcresultsetrowset

How RowSet works java?


I am trying to understand the internal workings of RowSet.

How does it set the properties data and create a connection?

RowSetFactory factory = RowSetProvider.newFactory();

JdbcRowSet jdbcRowSet = factory.createJdbcRowSet(); 

jdbcRowSet.setUrl( … );
jdbcRowSet.setUsername( … );
jdbcRowSet.setPassword( … );
jdbcRowSet.setCommand( … );

jdbcRowSet.execute();

Solution

  • The easiest way is to look at the default implementation com.sun.rowset.JdbcRowSetImpl.

    This class has a method connect() that establishes the connection.

    It does this in one of three ways:

    No magic here, it does the same things that you would do if you were to open a connection yourself.