We help IT Professionals succeed at work.

Check out this week's podcast, "Dairy Farms to Databases: Community's Hand in Technology"Listen Now


RMI does not compile!

sdaxm11 asked
Last Modified: 2013-12-29
i have been trying to get this porgram to work but some how it does not want to compile
basicly the program is a three tier JDBC program.
i am using JDK 1.1.5
could some pls have a look

the program is
**********************interface **********************************88
import java.rmi.*;

public interface out extends java.rmi.Remote
public Vector data(String SQLSearch) throws java.rmi.RemoteException;

**************************server side*****************************************
import java.rmi.*;
import java.rmi.server.UnicastRemoteObject;
import java.sql.*;
import java.util.*;

public class outImpl extends UnicastRemoteObject implements out{

private String SQL;

  public outImpl (String s) throws java.rmi.RemoteException {
                                                            }     // end of constructor
public Vector data(String SQLSearch) throws Remote.Exception {
      public static ResultSet rs;
       public Vector results;  
      private  boolean more;
      String url = "jdbc:odbc:project";
       query = "select * from company_job where title like"+SQLSearch;
      try {

                  // Load the jdbc-odbc bridge driver
                  Class.forName ("sun.jdbc.odbc.JdbcOdbcDriver");
            }                  // end of try

        catch(Exception ex){
      //setError("I am not doing anything because "+ex);
                  }            // catch expection


      Vector results=new Vector();
      Connection con= DriverManager.getConnection (url, "", "");
      Statement stmt = con.createStatement();
             ResultSet rs =stmt.executeQuery(query);
       boolean more = rs.next();

       while (more) {
        String s=rs.getString(5);
      //java.io.InputStream Notes=rs.getAsciiStream("Notes");
      String k=rs.getString(8);
      String text=s;
      String text1=k;
        more = rs.next();
      }     // end of while
               } // end of try

      catch(SQLException ex){
      throw new IllegalArgumentException("Data " +" not found");
                        }                  // catch statment

      }  // data


  public static void main(String args[]) {
    // Create and install a security manager
    System.setSecurityManager(new RMISecurityManager());

    try {
      outImpl obj = new outImpl("Results");
      Naming.rebind("Results", obj);
      System.out.println("outServer bound in registry");
      }  //end of try

       catch (Exception e) {
      System.out.println("outServer err: " + e.getMessage());
         } // end of catch

  } // end of public main

}  // end of class

*************************client side*******************************

import java.awt.*;
import java.applet.*;
import java.awt.event.*;
//import java.applet.Applet;
import java.sql.*;
import java.util.*;
import java.rmi.*;

  modify by katt on 13 feb
   ver 1.0

public class outClient extends Applet implements  Runnable{

      private Thread worker;
      public static Vector queryResults;
      private String message="Initializing";
      public static ResultSet rs;
       public Vector results;
      public static int currpos;
          public static int      maxrows;
      private  boolean more;
      public static int x;

      Label label1;
      TextField txtSearch;
      Button btnSearch;
      Button btnNext;
      Button btnClear;
      Button btnPrev;
      //*******************end of layout****************

      String query;
public synchronized void start(){
            if (worker==null){
            message ="connecting to databse";
            worker=new Thread(this);
                        }//end start

public void run(){

      // ********************create button*************************
      label1=new Label("Enter Search :");
        label1.setFont(new Font("Dialog",Font.PLAIN,10));
        label1.reshape(insets().left + 6,insets().top + 7,78,13);
      txtSearch=new TextField(10);
        txtSearch.setFont(new Font("Dialog",Font.PLAIN,10));
        txtSearch.reshape(insets().left + 96,insets().top + 7,84,19);

      btnSearch=new Button("Search");
        btnSearch.setFont(new Font("Dialog",Font.PLAIN,10));
      btnSearch.reshape(insets().left + 272,insets().top + 7,60,26);  
      btnClear=new Button("Clear");
        btnClear.setFont(new Font("Dialog",Font.PLAIN,10));
      btnClear.reshape(insets().left + 335,insets().top + 7,60,26);  

      btnNext=new Button("Next");
        btnNext.setFont(new Font("Dialog",Font.PLAIN,10));
      btnNext.reshape(insets().left + 272,insets().top + 400,60,26);  

      btnPrev=new Button("Previous");
        btnPrev.setFont(new Font("Dialog",Font.PLAIN,10));
      btnPrev.reshape(insets().left + 210,insets().top + 400,60,26);  
      //***************And on the 7th day, god rested from creating************      

      //**************Me listen to do something*****************
            btnSearch.addActionListener( new ActionListener()
              { public void actionPerformed( ActionEvent e )
                    { btnSearchClicked(); } } );
      btnClear.addActionListener( new ActionListener()
              { public void actionPerformed( ActionEvent e )
                    { btnClearClicked(); } } );

      btnNext.addActionListener( new ActionListener()
              { public void actionPerformed( ActionEvent e )
                    { btnNextClicked(); } } );

      btnPrev.addActionListener( new ActionListener()
              { public void actionPerformed( ActionEvent e )
                    { btnPrevClicked(); } } );
      //**************Me say do nothing important really********

            }// end or run
public void btnPrevClicked(){

public void btnNextClicked(){
       if ( currpos + 1 <= maxrows ) {
                       } // end of if
     else {
       currpos = maxrows;

}//end next click


       public void btnSearchClicked()
             {   String bSearch = txtSearch.getText();
             try {
                        out obj = (out)Naming.lookup("//" +
                                getCodeBase().getHost() + "/Results");
                     } catch (Exception e) {
                        System.out.println("out exception: " +
      maxrows = results.size();

      //}// end of try statment

      /*catch(SQLException ex){
                        }// catch statment
      }// button clicked end

//*******************end of search*************************

      public synchronized void paint(Graphics g){
      if (queryResults==null){
      if (txtSearch.getText()==null){
      String Empty="Pls enter search query";
      int y=70;

            while( currpos <maxrows || x<=2 ){      
            String text =(String)queryResults.elementAt(currpos);      


       public void

private synchronized void setError(String mess){

private synchronized void setResults(Vector results){

}// end of class
Watch Question


Adjusted points to 150

What messages do you get?

In the interface add
import java.util.Vector;

In the server code, procedure

public Vector data(String SQLSearch) throws Remote.Exception {
    public static ResultSet rs;
      public Vector results;    
    private  boolean more;

Change Remote.Exception to RemoteException

Remove all the modifiers from you method variables (or make them instance/class variables). Method variables cannot be public or static. Only the ones defined in the class can have those modifiers.

You seem to have many more problems in you code, but why don't you fix those first.


ok i have tried that(i works too)  but basicly i need the program to compile, if anyone can do this i will raise the points 200


Adjusted points to 200
This one is on us!
(Get your first solution completely free - no credit card required)


ok it complies
Unlock the solution to this question.
Join our community and discover your potential

Experts Exchange is the only place where you can interact directly with leading experts in the technology field. Become a member today and access the collective knowledge of thousands of technology experts.

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.


Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.