keep getting an exception with cachedRowSetImpl java.sql.SQLException: writeData cannot determine table name

::When i go to accept any changes to a cachedRowSetImpl i end up getting this error.

java.sql.SQLException: writeData cannot determine table name

::The source code is as follows i first call it in one class like so

     sqlUtil.commitToDatabase(onlineSrvrNm, onlineCRS);

::And the commitToDatabase method is as follows:

    public boolean commitToDatabase(String ServerName, CachedRowSetImpl crs) {
        Connection con = null;
       
        try {
            conSet.setServer(ServerName);
            Driver d = (Driver)Class.forName( conSet.getDriver() ).newInstance();
            con = DriverManager.getConnection(conSet.getServerPath(), conSet.getUser(), conSet.getPass());
            System.out.println("sqlUtilities.commitToDatabase: Database connection established");
           
            // propagate changes and close connection
            crs.acceptChanges(con);
            crs.close();
            con.close();
           
            return true;
           
        } catch (SQLException se) {
            System.err.println("sqlUtilities.commitToDatabase:" + se.getMessage() + "Exception--" + se.toString());
                    return false;
           
        } catch (Exception e) {
            System.err.println("sqlUtilities.commitToDatabase:" + e.getMessage() + " Exception--" + e.toString());
                    return false;
        }
    }

::The error occurs on the line crs.acceptChanges(con) I also tried placing the accept changes directly in the first class instead of doing it this way and i get the same error so it's not the way i am passing it. And incase the problem is where i am populating the CachedRowSet here is the method i am using for that

 public CachedRowSetImpl getCachedRowSet(String ServerName, String sqlQry){
       
        //import com.sun.rowset.CachedRowSetImpl;
        ResultSet rs;
        Connection con = null;
        CachedRowSetImpl crs;
        try {
            conSet.setServer(ServerName);
            Driver d = (Driver)Class.forName( conSet.getDriver() ).newInstance();
            con = DriverManager.getConnection(conSet.getServerPath(), conSet.getUser(), conSet.getPass());
            System.out.println("sqlUtilities.getResultSet:Database connection established");
            Statement stmt = con.createStatement();
            rs = stmt.executeQuery(sqlQry);
            crs = new CachedRowSetImpl();
            crs.populate(rs);
           
            // note that the connection is being closed
            con.close();
            return crs;
        } catch (Exception e){
            System.err.println("sqlUtilities.getResultSet:Cannot connect to database server" + e.toString());
        }
        return null;
    }
LVL 2
ethnarchAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

nayernaguibCommented:
Try using crs.setTableName("myTableName") before updating the database as follows:

  crs.setTableName("myTableName");
  crs.acceptChanges(con);

_______________

  Nayer Naguib
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
ethnarchAuthor Commented:
::i get this error now, but it doesn't list the 3 conflicts nor am i sure what kind of conflicts it's referring to

   3 conflicts while synchronizing Exception--javax.sql.rowset.spi.SyncProviderException: 3 conflicts while synchronizing
0
ethnarchAuthor Commented:
::nevermind i typed the tablename wrong, my mistake i think it's working now
0
ethnarchAuthor Commented:
Is it normal to have to set the tablename, I mean why doesn't it store the tablename when you populate the cachedRowSet
0
nayernaguibCommented:
I think populating the cachedRowSet only adds a collection of rows to the crs object.

This is what the error indicates anyway. :-)

_______________

  Nayer Naguib
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Programming

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.