Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/305.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/database/9.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何处理java.io.InvalidClassException?_Java_Database_Serialization_Ooad_Or Mapper - Fatal编程技术网

如何处理java.io.InvalidClassException?

如何处理java.io.InvalidClassException?,java,database,serialization,ooad,or-mapper,Java,Database,Serialization,Ooad,Or Mapper,请告诉我我该怎么做这个异常即将发生,我不知道如何删除它 java.io.InvalidClassException:applyonline.applicator;本地类 不兼容:stream classdesc serialVersionUID=8333391523914038903, 本地类SerialVersionId=-6432228733925744354 公共类申请人实现可序列化{ 公共字符串getId(){ 返回id; } 公共字符串getPassword(){ 返回密码; } 公共

请告诉我我该怎么做这个异常即将发生,我不知道如何删除它

java.io.InvalidClassException:applyonline.applicator;本地类 不兼容:stream classdesc serialVersionUID=8333391523914038903, 本地类SerialVersionId=-6432228733925744354

公共类申请人实现可序列化{
公共字符串getId(){
返回id;
}
公共字符串getPassword(){
返回密码;
}
公共无效集合id(字符串id){
this.id=id;
}
public void setPassword(字符串密码){
this.password=密码;
}
公共申请人(){
}
公共布尔checkLogin(stringid,stringpasword)抛出SQLException、IOException、ClassNotFoundException
{
db dbhandlerobj=new db();
ArrayList应用程序列表;

/*--->*/appList=dbhandlerobj.getObject(“申请人”、“申请人信息”);/*您正在使用不同版本的申请人类。可能您首先将申请人类对象写入数据库,然后修改了该类。这就是您收到此消息的原因

再次将对象写入数据库,然后尝试对其进行反序列化

    public class Applicant implements Serializable{

        public String getId() {
            return id;
        }

        public String getPassword() {
            return password;
        }

        public void setId(String id) {
            this.id = id;
        }

        public void setPassword(String password) {
            this.password = password;
        }

        public Applicant() {
        }
        public boolean checkLogin(String id,String pasword) throws SQLException, IOException, ClassNotFoundException
        {
            db dbhandlerobj=new db();
            ArrayList<Object> appList;
 /*  ----> */   appList = dbhandlerobj.getObject("Applicant","ApplicantInfo"); /* <------*/
            for(Object obj: appList)
            {
                Applicant app=(Applicant)obj;
                System.out.println("ID:::::"+app.getId());
                if(app.getId().equals(id) && app.getPassword().equals(pasword))
                {
                    return  true;
                }
            }
            return false;
        }
        private String id;
        private String password;
    }
public class db {
    Connection con;
    String host="jdbc:derby://localhost:1527/Hamza";
    String userName="Hamza";
    String pasword="123";
    public db() throws SQLException {

        this.con =DriverManager.getConnection(host, userName, pasword);
    }
    public void storeObject(Object object,String name) throws IOException, SQLException
    {
        PreparedStatement ps;
        ByteArrayOutputStream baos =new ByteArrayOutputStream();
        ObjectOutputStream obos=new ObjectOutputStream(baos);
        obos.writeObject(object);
        obos.flush();
        obos.close();
        baos.close();
        byte []data=baos.toByteArray();
        String sql="insert into "+name+" values(?)";
        ps=con.prepareStatement(sql);
        ps.setObject(1,data);
        ps.executeUpdate();
    }
    public ArrayList<Object> getObject(String tableName,String columnName) throws SQLException, IOException, ClassNotFoundException 
    {
        PreparedStatement ps;
        String sql="select * from "+tableName;
        ps=con.prepareStatement(sql);
        ResultSet rs=ps.executeQuery();
        ArrayList<Object> studentList=new ArrayList<Object>();
        while(rs.next())
        {
            try (ByteArrayInputStream bais = new ByteArrayInputStream(rs.getBytes(columnName))) {
                ObjectInputStream obis;
                obis = new ObjectInputStream(bais);
                studentList.add((Object)obis.readObject()); //<----ERROR IN THIS METHOD
            }
        }        
        return studentList;
    }  
}**