rmi and object references

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top