• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

RMI Exception! Please give me a hand!

 
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi!
When a client invoke loginIn() ,the client throw a remoteException.
java.rmi.UnmarshalException:error unmarshalling return;nested exception is:
java.io.WriteAbortedException:writing aborted;
java.io.NotSerialzableException erson
I defined a Person class.
the code of loginIn() in the Server:
public Vector loginIn(int qno) throws Exception {
String sql1,sql2;
Vector customers=new Vector();
sql1="select * from relation_table where Customer1="+qno;
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver").newInstance();
Connection con=null;
String url="jdbc dbc:JICQ";
con=DriverManager.getConnection(url,"","");
Statement s1=con.createStatement (ResultSet.TYPE_SCROLL_INSENSITIVE,ResultSet.CONCUR_READ_ONLY);
Statement s2=con.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,ResultSet.CONCUR_READ_ONLY);
ResultSet rs1=s1.executeQuery(sql1);
rs1.last();
int count=rs1.getRow();
if(count==0){
System.out.println("Null!");
}
else{
rs1.first() ;
for(int i=0;i<count;i++){
int No=rs1.getInt("Customer2");
sql2="select * from login_table where qno="+No;
ResultSet rs2=s2.executeQuery(sql2);
if(!rs2.next()){
System.out.println("Some Exceptions!");
}
else{
String nick=rs2.getString("Nickname");
Person p=new Person(No,nick);
customers.addElement(p);
}
if((i+1)==count) {
break;
}
rs1.next();

}
}
return customers;
}
Thanx!
 
author and jackaroo
Posts: 12200
280
Mac IntelliJ IDE Firefox Browser Oracle C++ Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Allen,
I take it that your Person class is on the server.
If you want your Person class to download to the client machine and run there, then you would make it implement Serializable.
If you want your Person class to run on the server, you would make it extend UnicastRemoteObject.
If you do not specify where you want your code to run, then RMI will check if your class is Serializable and give you the exception you have already noticed if it is not.
I wrote some code that demonstrates both ways of using RMI. You can find it at the bottom of this thread (second last post).
There are some tutorials listed on Sun's RMI page http://java.sun.com/j2se/1.4.1/docs/guide/rmi/
You might also want to look at the JGuru RMI short course at http://developer.java.sun.com/developer/onlineTraining/rmi/RMI.html
Regards, Andrew
 
allen gu
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanx!
 
mooooooo ..... tiny ad ....
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic