This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Distributed Java and the fly likes need help.  I have problems running the client Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Distributed Java
Bookmark "need help.  I have problems running the client" Watch "need help.  I have problems running the client" New topic

need help. I have problems running the client

bobby, morkos
Ranch Hand

Joined: Jan 04, 2002
Posts: 82
I have made an applet and I want to call my rmi Server. My server is register and the object is bounded to the registry. However, I took the applet and the stub and put in within another computer. Nothing happens, How do I get it to work. I think that the stub is not seen in my client application, but I don't know what to do. Could anyone please help?
This is my html (main.html):
<HEAD><TITLE>Data Base Demo</TITLE></HEAD>
<H1>DataBase using RMI</H1>
<APPLET CODE="DBApplet.class" WIDTH = 600 HEIGHT = 600>

This is my applet (DBApplet.class):
import java.rmi.*;
import java.applet.*;
import java.awt.*;
import java.awt.event.*;
public class DBApplet extends Applet {
private Button submit = new Button("Submit Query");
private TextField sql = new TextField("",50);
private TextArea ans = new TextArea();
private DbServer obj;
public void init() {
try {
obj = (DbServer)Naming.lookup("/Server");
submit.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e){
try {
String s = sql.getText();
} catch(Exception e1) {
System.out.println("DBApplet exception :"+e1.getMessage());
} catch (Exception e) {
System.out.println("DBApplet exception :" + e.getMessage());
This is my Server:
public interface DbServer extends java.rmi.Remote {
public abstract String query(String sql) throws java.rmi.RemoteException;
import java.sql.*;
import java.rmi.*;
import java.rmi.server.*;
public class Server extends UnicastRemoteObject implements DbServer {
private Connection connection;
private Statement statement;
private ResultSet rs;
private String name;
public Server(String Sname, String Spassword) throws RemoteException {
String name = Sname;
String password = Spassword;
String connectionURL = "jdbc:mysql://";
connection = null;
statement = null;
rs = null;
try {
connection = DriverManager.getConnection(connectionURL, name, password);
} catch(Exception e) {
System.out.println("Failed " + e.getMessage());
public void display() {
try {
Statement st = connection.createStatement();
ResultSet rs = st.executeQuery("SELECT * FROM log");
while ( {
System.out.println(rs.getString(1) + " - " + rs.getString(2) + " - " + rs.getString(3));
catch(SQLException e) {
System.out.println(">>Failed " + e.getMessage());
public String query(String sql) {
try {
Statement st = connection.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,
ResultSet r = st.executeQuery(sql);
StringBuffer s = new StringBuffer();
while ( {
s.append(r.getString(1) + " - " + r.getString(2) + " - " + r.getString(3) + "\n");
return s.toString() ;
} catch(SQLException e) {
System.out.println(">>Failed " + e.getMessage());
return "";
public static void main(String [] args) throws RemoteException {
// Starting RMIRegistry programmatically
try {
System.out.println("RMI registry ready.");
} catch (Exception e) {
System.out.println("Exception starting RMI registry:");
//Security Policy
if (System.getSecurityManager() == null) {
System.setSecurityManager(new RMISecurityManager());
//JNDI Path, naming which is going to belooked up from the server
String name = "/Server";
//Initiating Server and binding the object to the Server
try {
Server obj = new Server("rassaad", "newtrade");
Naming.rebind(name, obj);
System.out.println("Server bound in registry");
} catch (Exception e) {
System.out.println(">> Impl err: " + e.getMessage());
[ February 28, 2002: Message edited by: bobby, morkos ]
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
subject: need help. I have problems running the client
Similar Threads
Multithreading client socket throws Stream corrupted exception
Applet with RMI ,how to place into Tomcat?
If statement problem!!
error: "java.rmi.NotBoundException: Server" ???