Hi I have written a RMI application where i want to fetch the REcord from the Other Machine.But i t is not Woring
Code is as given Below
It throws MarshelException
Code is
import java.rmi.*;
import java.sql.*;
public interface AddServerIntf2 extends Remote{
ResultSet disp(
String name)throws RemoteException;
}
import java.rmi.*;
import java.rmi.server.*;
import java.sql.*;
public class AddServerImpl2 extends UnicastRemoteObject
implements AddServerIntf2{
public AddServerImpl2() throws RemoteException{
}
//void disp(String name,ResultSet rs1) throws RemoteException
public ResultSet disp(String name) throws RemoteException
{
String url="jdbc
dbc:group";
ResultSet rs1=null;
Connection c;
PreparedStatement ps;
try{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
c=DriverManager.getConnection(url);
name="select * from "+name;
ps=c.prepareStatement(name);
return(rs1=ps.executeQuery());
}
catch(SQLException se){System.out.println("SQLException : "+se); }
catch(Exception e){System.out.println("Exception : "+e);}
return rs1;
}
}
import java.rmi.*;
import java.net.*;
public class AddServer2 {
public static void main(String ar[]){
try{
AddServerImpl2 a2=new AddServerImpl2();
Naming.rebind("AddServer2",a2);
}
catch(Exception e){System.out.println("Exception Caught : "+e);}
}
}import java.rmi.*;
import java.sql.*;
public class AddClient2{
public static void main(String ar[]){
try{
String URL="rmi://"+ar[0]+"/AddServer2";
AddServerIntf2 aa = (AddServerIntf2) Naming.lookup(URL);
System.out.println("Records from "+ar[1]);
System.out.println("Rollno Name");
ResultSet rs=aa.disp(ar[1]);
if(rs!=null)
{
while(rs.next()){
int i=rs.getInt("rollno");
String ss=rs.getString("name");
System.out.println(i+" "+ss);
}
}
}
catch(Exception e){System.out.println("Exception Caught : "+e);}
}
}