I need to deserialize() a Java object stored in a BLOB. Database instance has no server-side Java loaded, and never gets one. I can't connect to the database with a Java code, only with SQL client such as TOAD. So the only option seems to be, implement deserialization in PL/SQL. Any ideas, how?
-
You don't have a JDBC driver to connect to the database from your application? If not how would you provide the data to deserialize to any PL/SQL and how would you trigger? - What you might try in this case: deserialize to a file and load that file into a blob manually.Thomas– Thomas2015-12-15 10:19:02 +00:00Commented Dec 15, 2015 at 10:19
-
Possible duplicate of deserialize java object from a blobKraal– Kraal2015-12-15 10:22:31 +00:00Commented Dec 15, 2015 at 10:22
-
@Thomas, no I can't connect from any external / unapproved app including Java including JDBC Driver, it's about security and it's strict. Serialized Java Object is stored in a BLOB by another (approved) app.k0a1a– k0a1a2015-12-15 10:23:41 +00:00Commented Dec 15, 2015 at 10:23
-
@Kraal, it's no duplicate because I can't use Java, neither server- nor client-side.k0a1a– k0a1a2015-12-15 10:24:38 +00:00Commented Dec 15, 2015 at 10:24
-
If you can't use Java anywhere, why would you have a serialized Java object in the database?Kayaman– Kayaman2015-12-15 10:28:19 +00:00Commented Dec 15, 2015 at 10:28
1 Answer
I don't know what you're trying to achieve, but if there is no way to ask your "approved java app" to write the data you need in a readable form (is the data stored by a 3d party application you bought ? If so, can't they provide you with a tool to achieve what you want ?) , and if you can't write your own java program to read these serialized object, I guess that the only way to do what you're trying to achieve is:
- Read the Java Object Serialization specification located at https://docs.oracle.com/javase/8/docs/platform/serialization/spec/serialTOC.html (for JDK 8)
- Make sure you know the class you want to analyse (if objects are an instance of different classes this may help you filter the objects you're looking for)
- Deserialize in PL/SQL the objects by following the serialization stream format and read the fields you're looking for.
This article can help you understand the serialization algorithm : http://www.javaworld.com/article/2072752/the-java-serialization-algorithm-revealed.html
Note: I do not recommend this approach, you should rather find a way to store the data in a readable format.