Detailed explanation of MySQL storing Java object instances
•
Java
MySQL stores Java objects
MySQL sets the field to blob
To save an object, first serialize the object as byte [] and use setobject (byte [] bytes)
Get the object. Use getbytes() to deserialize the obtained byte [] into a Java object
There will be various problems in other online methods. Please use them with caution.
include:
1. Set the URL parameter autodeserialize = true 2 Setobject (Java instance object) query
ObjectInputStream oips = new ObjectInputStream(rs.getBinaryStream(1)); ArrayList < string > OBB = (Java class) oips readObject();// Read object from stream
Thank you for reading, hope to help you, thank you for your support to this site!
The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
二维码