简体   繁体   English

ResultSet错误java.rmi.UnmarshalException

[英]ResultSet Error java.rmi.UnmarshalException

I am trying to execute the query on server side and send the result to the client but at the time of returning the value to the client the error occurs Am trying to achieve this using RPC Protocol but i could not find out how to send back the resultset from server to client and am using sqlite database 我正在尝试在服务器端执行查询并将结果发送给客户端,但是在将值返回给客户端时发生错误我正在尝试使用RPC协议实现此目的,但是我找不到如何发回从服务器到客户端的结果集,并且正在使用sqlite数据库

Client: 客户:

public class client {

public static void main(String[] args) { 
ResultSet rs;
    try {
        inter Inter = (inter) Naming.lookup("rmi://localhost/collegeDBImpl");
         System.out.println("Handle to Server Object Acquired");  
         BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
         System.out.println("username");
         String username=br.readLine();
         System.out.println("pass");
         String password=br.readLine();
         rs=Inter.loginDB(username, password);
    } catch (NotBoundException ex) {
        Logger.getLogger(client.class.getName()).log(Level.SEVERE, null, ex);
    } catch (MalformedURLException ex) {
        Logger.getLogger(client.class.getName()).log(Level.SEVERE, null, ex);
    } catch (RemoteException ex) {
        Logger.getLogger(client.class.getName()).log(Level.SEVERE, null, ex);
    }catch(Exception e){
        System.out.println(e);
    }



   }
}

Server: 服务器:

public class server {
    public static void main(String[] args) throws Exception {
                        impl li=new impl();
            System.out.println("Server Started");
            Naming.rebind("collegeDBImpl",li);
            System.out.println("Server Object Registered");
    }

}

inter.java 跨java

   public interface inter extends Remote{
         public ResultSet loginDB(String username, String password)throws RemoteException; 
    }

impl.java: impl.java:

public class impl  extends UnicastRemoteObject  implements inter{

    Connection conn=null;
    ResultSet rs=null;
    PreparedStatement pst = null;
    impl()throws RemoteException{        
        conn=javaConnect.ConnecrDb();
    }

    @Override
    public ResultSet loginDB(String username, String password) throws RemoteException {
        String sql="Select * from studentDetails where username=? and password=?";
       try{
       pst=conn.prepareStatement(sql);
       pst.setString(1, username);
       pst.setString(2, password);
       rs=pst.executeQuery();
       if(rs.next()){
           JOptionPane.showMessageDialog(null, "Username and password is correct");
       }else{
            JOptionPane.showMessageDialog(null, "Username and password is not correct");
       }
       }catch(Exception e){
           JOptionPane.showMessageDialog(null, e);           
       }
       return rs;
    }

}

ResultSet isn't serializable right? ResultSet不可以序列化吗? So add your results to a serializable DTO and pass that back instead 因此,将结果添加到可序列化的DTO并将其传递回去

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 RMI 调用中的 java.rmi.UnmarshalException - java.rmi.UnmarshalException in RMI call RMI客户端无法查找服务器-java.rmi.UnmarshalException - RMI client cannot lookup server - java.rmi.UnmarshalException java.rmi.UnmarshalException: 解组参数错误; 嵌套异常是:java.lang.ClassNotFoundException: ServicesTableau - java.rmi.UnmarshalException: error unmarshalling arguments; nested exception is: java.lang.ClassNotFoundException: ServicesTableau weblogic上下文查找错误:java.rmi.UnmarshalException:错误解组参数 - weblogic context lookup error : java.rmi.UnmarshalException: error unmarshalling arguments java.rmi.UnmarshalException:无法通过服务器提取客户端类 - java.rmi.UnmarshalException: unable to pull client classes by server 远程对象不支持RMI方法:java.rmi.UnmarshalException:无法识别的方法哈希 - RMI Method not supported by remote object: java.rmi.UnmarshalException: unrecognized method hash java.rmi.UnmarshalException:无法识别的方法hash:远程对象不支持的方法 - java.rmi.UnmarshalException: unrecognized method hash: method not supported by remote object 获取java.rmi.UnmarshalException:无法识别的方法哈希:远程对象不支持的方法 - Getting java.rmi.UnmarshalException: unrecognized method hash: method not supported by remote object java.rmi.UnmarshalException:java.lang.ClassNotFoundException。 无法使用RMI从另一个物理JVM访问类 - java.rmi.UnmarshalException: java.lang.ClassNotFoundException. Can't get acces to class from another physical JVM using RMI Rmi UnmarshalException:错误解组返回 - Rmi UnmarshalException: error unmarshalling return
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM