Anubhav kalra
Anubhav kalra

Reputation: 65

java.sql.SQLException: Provider com.sun.rowset.RowSetFactoryImpl not found

I've asked a question on how to retrieve data from ResultSet before closing the connections.

JDK Version: jdk1.8.0_201

CachedRowSet class is suggested in an answer by someone in the above mentioned question. I've tried going with that approach but got an exception when try to run the program.

java.sql.SQLException: Provider com.sun.rowset.RowSetFactoryImpl not found

As per my analysis, packages of com.sun are internal and are subjected to change. They should never be used except by JDK developers.

Suggest me something to resolve this.

Here is my code

/*--- Imports of classes---*/
import javax.sql.rowset.CachedRowSet;
import javax.sql.rowset.RowSetProvider;
/*--- End of Imports ---*/

public ResultSet getUSStates() throws SQLException {
    _log.info("Calling stored proc for ocrt give data");

    try(Connection inGlobalConnections = getConnection();
        CallableStatement callableStatement = inGlobalConnections.prepareCall("{call mst.USP_GetUSStates()}");
        ResultSet resultSet = callableStatement.getResultSet();) {

        callableStatement.execute();

        CachedRowSet cachedRowSet = RowSetProvider.newFactory().createCachedRowSet();
        cachedRowSet.populate(resultSet);

        return cachedRowSet;
    } catch (Exception e) {
        _log.error(e, e);
    }

    return null;
}

Upvotes: 0

Views: 75

Answers (0)

Related Questions