rmi and object references

Discussion in 'Java' started by kevin, Nov 5, 2004.

  1. kevin

    kevin Guest


    I've got a problem trying to reference a remote object via a

    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
    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) {
    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.
    kevin, Nov 5, 2004
    1. Advertisements

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 (here). After that, you can post your question and our members will help you out.