?
Solved

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

Posted on 2006-04-03
5
Medium Priority
?
999 Views
Last Modified: 2012-06-27
::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;
    }
0
Comment
Question by:ethnarch
  • 3
  • 2
5 Comments
 
LVL 14

Accepted Solution

by:
nayernaguib earned 1000 total points
ID: 16362416
Try using crs.setTableName("myTableName") before updating the database as follows:

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

_______________

  Nayer Naguib
0
 
LVL 2

Author Comment

by:ethnarch
ID: 16362503
::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
 
LVL 2

Author Comment

by:ethnarch
ID: 16362532
::nevermind i typed the tablename wrong, my mistake i think it's working now
0
 
LVL 2

Author Comment

by:ethnarch
ID: 16362546
Is it normal to have to set the tablename, I mean why doesn't it store the tablename when you populate the cachedRowSet
0
 
LVL 14

Expert Comment

by:nayernaguib
ID: 16362760
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

Featured Post

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If you’re thinking to yourself “That description sounds a lot like two people doing the work that one could accomplish,” you’re not alone.
Q&A with Course Creator, Mark Lassoff, on the importance of HTML5 in the career of a modern-day developer.
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…
Starting up a Project

850 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question