Results 1 to 3 of 3
  1. #1
    Join Date
    Mar 2004
    Posts
    1

    Unanswered: CachedRowSetImpl Init Problem

    Hi all,

    I'm facing a problem while constructing CachedRowSetImpl instance by saying "CachedRowSetImpl crs = new CachedRowSetImpl()". The code in double quotes, when executed, is throwing "java.lang.NullPointerException".

    The stack trace is as below, kindly help me out, this is very urgent.

    java.lang.NullPointerException
    at java.io.Reader.<init>(Reader.java:61)
    at java.io.InputStreamReader.<init>(InputStreamReader .java:80)
    at java.util.Properties.load(Properties.java:266)
    at javax.sql.rowset.spi.SyncFactory.initMapIfNecessar y(SyncFactory.java:371)
    at javax.sql.rowset.spi.SyncFactory.getInstance(SyncF actory.java:557)
    at com.sun.rowset.CachedRowSetImpl.<init>(CachedRowSe tImpl.java:224)

    Thank you very much,

    Regards,
    Ramesh M.

  2. #2
    Join Date
    Mar 2004
    Posts
    1

    Red face same problem!!!

    Hi I am having the same damn problem and I am wondering if u have found any work arounds or solutions to this frustrating problem!! I have spent enough time already on this and it's really driving me nutts, it seems to me like there is something wrong with respect to the serialization of the cachedrowset object as I get an RMIException when trying to send the CachedRowSet object remotely from the bussiness tier to the web tier.

    I have been able to use CachedRowSets, here is a working example based on a non working piece of code that I found on the net and that I have changed (PS: rowset.jar needed)

    import java.sql.*;
    import javax.sql.rowset.*;
    import com.sun.rowset.CachedRowSetImpl;

    public class mytest
    {

    public static void main(String args[]) {
    try {
    CachedRowSet crs = new CachedRowSetImpl();
    RowSetMetaDataImpl rsmdi;
    rsmdi = new RowSetMetaDataImpl();
    rsmdi.setColumnCount(3);
    rsmdi.setColumnType(1, Types.VARCHAR);
    rsmdi.setColumnType(2, Types.INTEGER);
    rsmdi.setColumnType(3, Types.VARCHAR);
    crs.setMetaData(rsmdi);

    crs.moveToInsertRow();

    crs.updateString(1, "StringCol11");
    crs.updateInt(2, 1);
    crs.updateString(3, "StringCol31");
    crs.insertRow();

    crs.updateString(1, "StringCol12");
    crs.updateInt(2, 2);
    crs.updateString(3, "StringCol32");
    crs.insertRow();

    crs.moveToCurrentRow();
    crs.beforeFirst();

    System.out.println(
    "Fetching from RowSet...");
    while (crs.next()) {
    showTheData(crs);
    } // end while next

    if (crs.isAfterLast() == true) {
    System.out.println(
    "We have reached the end");
    System.out.println("crs row: " +
    crs.getRow());
    }

    System.out.println(
    "And now backwards...");

    while (crs.previous()) {
    showTheData(crs);
    } // end while previous

    if (crs.isBeforeFirst() == true) {
    System.out.println(
    "We have reached the start");
    }

    crs.first();
    if (crs.isFirst() == true) {
    System.out.println(
    "We have moved to first");
    }

    System.out.println("crs row: " +
    crs.getRow());

    if (crs.isBeforeFirst() == false) {
    System.out.println(
    "We aren't before the first row.");
    }

    crs.last();
    if (crs.isLast() == true) {
    System.out.println(
    "...and now we have moved to the last");
    }

    System.out.println("crs row: " +
    crs.getRow());

    if (crs.isAfterLast() == false) {
    System.out.println(
    "we aren't after the last.");
    }

    } // end try
    catch (SQLException ex) {
    System.err.println("SQLException: " +
    ex.getMessage());
    ex.printStackTrace();
    }
    }

    public static void showTheData(CachedRowSet crs) throws SQLException {
    String sCol1,
    sCol3;
    sCol1 = crs.getString(1);
    int iCol2;

    if (crs.wasNull() == false) {
    System.out.println("sCol1: " + sCol1);
    } else {
    System.out.println("sCol1 is null");
    }

    iCol2 = crs.getInt(2);
    if (crs.wasNull() == false) {
    System.out.println("iCol2: " + iCol2);
    } else {
    System.out.println("iCol2 is null");
    }

    sCol3 = crs.getString(3);
    if (crs.wasNull() == false) {
    System.out.println("sCol3: " +
    sCol3 + "\n");
    } else {
    System.out.println("sCol3 is null\n");
    }

    }
    }

  3. #3
    Join Date
    Apr 2004
    Location
    Budapest
    Posts
    1

    Anyone figured this out yet?

    I'm having a similar problem when programmatically instantiating a CachedRowSet.
    java.lang.NullPointerException
    at java.io.Reader.<init>(Reader.java:61)
    at java.io.InputStreamReader.<init>(InputStreamReader .java:80)
    at java.util.Properties.load(Properties.java:266)
    at javax.sql.rowset.spi.SyncFactory.initMapIfNecessar y(SyncFactory.java
    371)
    at javax.sql.rowset.spi.SyncFactory.getInstance(SyncF actory.java:557)
    at com.sun.rowset.CachedRowSetImpl.<init>(CachedRowSe tImpl.java:224)
    at controls.CustomRowSetImpl.getMyRows(CustomRowSetIm pl.jcs:27)

    It seems like the zero parameter constructor would try to read some parameters from some non-existant property file, I will try to use the constructor with the HashMap to avoid it...

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •