Link to home
Start Free TrialLog in
Avatar of Cleare
Cleare

asked on

RMI Applet/server communication and connecting to a database

I am using RMI between an applet and a server. The RMI server is located on a machine called sun4 and part of what I needed to do was to allow a user to query, through the applet in a browser , a database located on another machine called macneill.

I kept getting security exceptions and couldn't understand why.  Eventually on "guess" advice from someone who suggested that the problem might be the second connection (ie the connection to macneill) since an applet can only connect to a server from which it is downloaded.

I relocated my RMI server to macneill and sure enough all is working. I don't understand why this should be.  This implies that the applet was trying to connect to macneill but I understood the whole point of RMI was that the server would carry out such connections and therefore working around the problem of an applet not being able to make a separate connection.

Why should it be a problem for the server to connect to a separate machine? Was I doing something wrong or is this to be expected? Unfortunately I need to clarify this for a detailed write up on the project

any help would be really appreciated.
thanks
Liz
Avatar of Mick Barry
Mick Barry
Flag of Australia image

Liz,

Were you making your db queries thry the RMI server, or were you making them directly? If you're making them directly then RMI is not even involved.
Avatar of Cleare
Cleare

ASKER

All the code to submit the queries was in the Implementation which admittedly was a separate class to the Server.  How could RMI not be involved if i have a server, client and have rmi compiled them?  
RMI is only used to talk to the RMI server.
JDBC and RMI are totally unrelated.
Avatar of Cleare

ASKER

i know they're unrelated but the problem is why can the server not carry out the JDBC stuff from a machine that is not necessarily the same machine as where the databse is?  I don't want or need the applet to connect directly to the database I understood that all that could be done on the server side.

What has happened implies to me that the implementation code is downloaded to the applet as well as the appletcode.  This would raise the problem that the applet cannot talk both to the server on one machine and the databse on another machine.

Is this the way RMI is supposed to work?

I thought the point of it was that the real implementation was carried out on the server side therefore eliminating any problems with the applet trying to connect to more than one machine.

I'm need to establish exactly where the implementation is being carried out.  Is it on the machine the applet is being downloaded to or is it on the server regardless of where the applet is?
Are your JDBC calls being made by the applet or the RMI server?
Avatar of Cleare

ASKER

All the JDBC code is in the server.  But now that you say it the methods that contain all the JDBC stuff are called on the interface in the applet.

For example the applet would contain the following:

private SInterface interface;
...
//set up GUI
//take in headword parameter from user
...

interface.findword(headword);

The method findword(String headword) is in the Implemetation and contains JDBC code.

I have 4 principle classes: the Server, the Implemetatio (all JDBC code is in here) the Interface and the applet.

I understood that calling those methods on an object of the interface means that they methods aren't beinng carried out on the applet side but remotely i the server.  Am I understanding that correctly?

thanks for replying so often this is really important....
Liz


Can you post the stack trace for the security exception uo are getting.
No comment has been added lately, so it's time to clean up this TA.
I will leave a recommendation in the Cleanup topic area that this question is:
PAQ'd and pts removed
Please leave any comments here within the next seven days.
 
PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!
 
Venci75
EE Cleanup Volunteer
ASKER CERTIFIED SOLUTION
Avatar of SpideyMod
SpideyMod

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial