K
kevin
hi,
I've got a problem trying to reference a remote object via a
reference.
I have a series of database classes subclassed from dbAccess, and a
remote method Map getTables() that returns a map (String tablename,
dbAccess table)
I can run this method, and locally cast out subclasses then user their
methods.
When I try to use this class reference in a method call, it seems to
use the class i changed locally, but not return it...
Anyone got an idea why it won't work an how to go about fixing /
avoiding it?
local code
rs.authorise("test", "user", "password"); // rmi authority check
tables = rs.getTables(); // read map of dbAccess classes
cust = (Customer) tables.get(cust.tableName); // get instance
cust.setId(" 101"); // use instance function to set key fld
blnOK = rs.readRow(cust); // call remote method using class ref.
if (blnOK) { // this returns true as it found key
// but the name is blank.
System.out.println("customer 101 is " + cust.getName());
}
server code
public boolean readRow( dbAccess table) throws RemoteException,
RemoteSQLException {
boolean blnFound = false;
if (livedb == null) {
throw new RemoteSQLException("No Connection");
}
try {
blnFound = table.readRow(livedb);
} catch (SQLException sqle) {
blnSQLError = true;
throw new RemoteSQLException(sqle.getMessage());
} finally {
// only kill connections if sql error happened
if (blnSQLError) {
dropConnections();
}
}
Customer cust = (Customer) table;
System.out.println("found row " + cust.getName());
tableclasses.put(table.tableName, table);
return blnFound;
}
this code correctly prints out the customer name to the console, yet
the class
reference is not updated locally, because that prints null.
I've got a problem trying to reference a remote object via a
reference.
I have a series of database classes subclassed from dbAccess, and a
remote method Map getTables() that returns a map (String tablename,
dbAccess table)
I can run this method, and locally cast out subclasses then user their
methods.
When I try to use this class reference in a method call, it seems to
use the class i changed locally, but not return it...
Anyone got an idea why it won't work an how to go about fixing /
avoiding it?
local code
rs.authorise("test", "user", "password"); // rmi authority check
tables = rs.getTables(); // read map of dbAccess classes
cust = (Customer) tables.get(cust.tableName); // get instance
cust.setId(" 101"); // use instance function to set key fld
blnOK = rs.readRow(cust); // call remote method using class ref.
if (blnOK) { // this returns true as it found key
// but the name is blank.
System.out.println("customer 101 is " + cust.getName());
}
server code
public boolean readRow( dbAccess table) throws RemoteException,
RemoteSQLException {
boolean blnFound = false;
if (livedb == null) {
throw new RemoteSQLException("No Connection");
}
try {
blnFound = table.readRow(livedb);
} catch (SQLException sqle) {
blnSQLError = true;
throw new RemoteSQLException(sqle.getMessage());
} finally {
// only kill connections if sql error happened
if (blnSQLError) {
dropConnections();
}
}
Customer cust = (Customer) table;
System.out.println("found row " + cust.getName());
tableclasses.put(table.tableName, table);
return blnFound;
}
this code correctly prints out the customer name to the console, yet
the class
reference is not updated locally, because that prints null.