我有一个数组,我从数据库ResultSet创建。我试图序列化它,以便我可以通过套接字流发送它。此刻,我得到一个错误,告诉我该数组不是Serializable。我的代码是向下跌破,第一部分是创建数组对象类:序列化一个对象数组以通过套接字发送
class ProteinData
{
private int ProteinKey;
public ProteinData(Integer ProteinKey)
{
this.ProteinKey = ProteinKey;
}
public Integer getProteinKey() {
return this.ProteinKey;
}
public void setProteinKey(Integer ProteinKey) {
this.ProteinKey = ProteinKey;
}
}
代码填充数组:
public List<ProteinData> readJavaObject(String query, Connection con) throws Exception
{
PreparedStatement stmt = con.prepareStatement(query);
query_results = stmt.executeQuery();
while (query_results.next())
{
ProteinData pro = new ProteinData();
pro.setProteinKey(query_results.getInt("ProteinKey"));
tableData.add(pro);
}
query_results.close();
stmt.close();
return tableData;
}
和代码来调用这个是:
和代码recieving是这样的:
List dataList = (List) input_stream.readObject();
有人可以帮我把这个阵列排成一列。我可以在论坛中找到的只是简单的数组(EG。int [])。
我试图添加serializable到类和UID号码,但得到java.lang.ClassNotFoundException: socketserver.ProteinData
错误消息。现在有人为什么?
感谢您的任何帮助。
我看不到你的代码中的任何阵列...只列出 –
2010-11-23 13:51:26