ok my first attempt at rmi/jdbc. I set up a simple class that interacts to the (mysql) db just fine. But when I try to adapt it to a three tier system, I get all sorts of remote errors. The odd thing is, I can add to the DB ok, I get the proper exception when a record to be added will be a duplicate. But if I try to remove an item or run a simple query, I get remote errors. I'm not sure why, because as I said.. I can add just fine. Anyone have any thoughts?
AddNewItem Code (that works)
public void addNewItem(String up, String de, String ud, int qu) throws ItemAlreadyExistsException, java.rmi.RemoteException {
try {
PreparedStatement ps = con.prepareStatement("INSERT INTO ITEMS VALUES( ?, ?, ?, ?);");
ps.setString(1, up);
ps.setString(2, de);
ps.setString(3, ud);
ps.setInt(4, qu);
ps.executeUpdate();
} catch (SQLException sql) {
// so you know somethin is happening here..
throw new ItemAlreadyExistsException();
}
}
DeleteItem Code (that doesn't work)
public void removeItem(String upc) throws NoSuchItemException, java.rmi.RemoteException{
try {
int changed = -1;
PreparedStatement ps = con.prepareStatement("DELETE FROM ITEMS WHERE UPC = ?");
ps.setString(1, upc);
changed = ps.executeUpdate();
if (changed <= 0)
throw new NoSuchItemException();
} catch (SQLException sql) {
throw new NoSuchItemException();
}
}
I tried out this code in the main of a really basic program, declaring the variable to use rather than passing it in, and it worked just fine. Not sure if this is any sort of security issue or what, but it's a class project and we all are using the same username/password to access the db.
thanks for any advice in advance...