ethnarch
asked on
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(o nlineSrvrN m, onlineCRS);
::And the commitToDatabase method is as follows:
public boolean commitToDatabase(String ServerName, CachedRowSetImpl crs) {
Connection con = null;
try {
conSet.setServer(ServerNam e);
Driver d = (Driver)Class.forName( conSet.getDriver() ).newInstance();
con = DriverManager.getConnectio n(conSet.g etServerPa th(), conSet.getUser(), conSet.getPass());
System.out.println("sqlUti lities.com mitToDatab ase: Database connection established");
// propagate changes and close connection
crs.acceptChanges(con);
crs.close();
con.close();
return true;
} catch (SQLException se) {
System.err.println("sqlUti lities.com mitToDatab ase:" + se.getMessage() + "Exception--" + se.toString());
return false;
} catch (Exception e) {
System.err.println("sqlUti lities.com mitToDatab ase:" + 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.CachedRowSe tImpl;
ResultSet rs;
Connection con = null;
CachedRowSetImpl crs;
try {
conSet.setServer(ServerNam e);
Driver d = (Driver)Class.forName( conSet.getDriver() ).newInstance();
con = DriverManager.getConnectio n(conSet.g etServerPa th(), conSet.getUser(), conSet.getPass());
System.out.println("sqlUti lities.get ResultSet: 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("sqlUti lities.get ResultSet: Cannot connect to database server" + e.toString());
}
return null;
}
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(o
::And the commitToDatabase method is as follows:
public boolean commitToDatabase(String ServerName, CachedRowSetImpl crs) {
Connection con = null;
try {
conSet.setServer(ServerNam
Driver d = (Driver)Class.forName( conSet.getDriver() ).newInstance();
con = DriverManager.getConnectio
System.out.println("sqlUti
// propagate changes and close connection
crs.acceptChanges(con);
crs.close();
con.close();
return true;
} catch (SQLException se) {
System.err.println("sqlUti
return false;
} catch (Exception e) {
System.err.println("sqlUti
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.CachedRowSe
ResultSet rs;
Connection con = null;
CachedRowSetImpl crs;
try {
conSet.setServer(ServerNam
Driver d = (Driver)Class.forName( conSet.getDriver() ).newInstance();
con = DriverManager.getConnectio
System.out.println("sqlUti
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("sqlUti
}
return null;
}
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
::nevermind i typed the tablename wrong, my mistake i think it's working now
ASKER
Is it normal to have to set the tablename, I mean why doesn't it store the tablename when you populate the cachedRowSet
I think populating the cachedRowSet only adds a collection of rows to the crs object.
This is what the error indicates anyway. :-)
_______________
Nayer Naguib
This is what the error indicates anyway. :-)
_______________
Nayer Naguib
ASKER
3 conflicts while synchronizing Exception--javax.sql.rowse