Our object:
import java.io.Serializable; ... class Account implements Serializable{ public String data; }
How to get our object from bd:
while (rs.next()) { Object accountJustObject = rs.getObject(i); Account account = (Account)accountJustObject; accounts.add(account); i++; }
How to save our object:
public void InsertAccount(int id, Account newaccount){ reparedStatement insertNew = conn.prepareStatement( "INSERT INTO root(id,account) VALUES (?,?)"; insertNew.setInt(1, id);
Checked in H2 database.
Ilja vost
source share