Help with Object Serialization to Database

Help with Object Serialization to Database

Post by WillWi » Sun, 16 Aug 1998 04:00:00



HELP!!!

Can anyone provide me with a bit of code, directions, or any helpful advice
whatever that will help me serialize objects and store them in a standard
relational database.  (Not ODBMS)

Any help would be GREATLY appreciated!


Thanks!
Will

 
 
 

Help with Object Serialization to Database

Post by Dirk P. Fromhei » Tue, 18 Aug 1998 04:00:00


I would suggest you take a look at our Relational Object Framework (ROF).

ROF allows you to "map" your Java objects into a standard relational database.
Unlike just munging it all into a blob, this approach allows you to query the
database based on member variables of the object.

Using ROF, Java programmers can create applications that interact with any
RDBMS without knowing SQL, the structure of the database, or managing the
connection layer via JDBC. This allows programmers to access an RDBMS without
any database specific coding.

Because ROF maintains its own model of the database and the class mappings, the
database structure and class definitions can change independently.

Give it a test http://www.watershed.com

Good luck,
Dirk Fromhein


> HELP!!!

> Can anyone provide me with a bit of code, directions, or any helpful advice
> whatever that will help me serialize objects and store them in a standard
> relational database.  (Not ODBMS)

> Any help would be GREATLY appreciated!


> Thanks!
> Will

  dpf.vcf
< 1K Download

 
 
 

Help with Object Serialization to Database

Post by Joseph Weinstei » Tue, 18 Aug 1998 04:00:00


Hi Will,

Here's a code snippet that shows object serialiation/deserialization
to/from a DBMS. The example is for Oracle, but except for the
DDL, it would be the same for any other DBMS. Lemme know if
it helps,
Joe Weinstein at WebLogic, Inc.

    stmt.executeUpdate("create table " + tablename + "(foo long raw)");
     pstmt = con.prepareCall("insert into " + tablename + " values(?)");
    Object o = "1234567890"; // A String object this time...

    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    ObjectOutputStream oos     = new ObjectOutputStream(baos);
    oos.writeObject(o);

    byte[] bytes = baos.toByteArray();
    ByteArrayInputStream bais = new ByteArrayInputStream(bytes);

    pstmt.setBinaryStream(1, bais, bytes.length);
    pstmt.executeUpdate();
    pstmt.close();

    rs = stmt.executeQuery("select * from " + tablename + "");

    while(rs.next())
    {
       java.io.InputStream x = rs.getBinaryStream(1);
       ObjectInputStream ox  = new ObjectInputStream(x);
       Object oout = ox.readObject();
       String objName = oout.getClass().getName();

        if (!objName.equals("java.lang.String"))
        { // deser. failed
        }
        if (!oout.equals(o))
        { // deser failed.
        }
    }


> HELP!!!

> Can anyone provide me with a bit of code, directions, or any helpful advice
> whatever that will help me serialize objects and store them in a standard
> relational database.  (Not ODBMS)
> Any help would be GREATLY appreciated!

> Thanks!
> Will

--

Joseph Weinstein        Staff Engineer
http://www.weblogic.com
See our newsgroups:       http://www.weblogic.com/services/newsgroups.html
try weblogic for free *with support*:  http://www4.weblogic.com/register.html

 
 
 

1. Serialization of objects stored persistently (and use of the transient modifier) sent to an applet

Forwarding on below email to this group as well...knowing that the diamond
in the rough could be here too...

Hi all,

Have couple of questions for the ObjectStore and Pattern experts out there.
So here is a detailed account of my current situation (in psuedo-pattern
catalogue detail).

Problem:
How to transfer over a persistent object via serialization but without
recursively serializing particular referred objects within the persistent
object (i.e., using transient modifier) so as not to inundate network
traffic to the end client where the applet will receive this serialized
object.

Participants:
* Applet (end client)
 - awaiting transfer of serialized object.
 - will make necessary calls for new serialized objects

* Serializable object
 - lightweight when serialized so as not to inundate traffic if associated
  object has thousands of recursive objects underneath it (i.e., this
  object is a Composite type object).
 - stored in the ObjectStore database (including all its children objects)

* ObjectStore (OO Database)
 - store the Serializable object and all its object references (recursively
of course).

Environment:
ObjectStore 5.1 (OSJI 1.3) running on Windows NT Workstation 4.0

Sample Code:
/**
 * Simple test class demonstrating what I want to do but not sure if it will
 * achieve my objectives.
 */
import COM.odi.util.*;

public class Test implements Serializable {
 Test() {
 }

 private transient OSVector list;

 //yadda, yadda...other fields and methods of interest that we do want
 //serialized

Questions:
1. First (for the ObjectStore experts), will the transient list object be
properly stored into ObjectStore?  Basically, I want to have Test class be
persistent capable class.  And I DO want the associated list object to be
stored in the database as well.

2. Second (for Patterns or ObjectStore experts), is this the best way to do
this?  A colleague of mine mentioned something about creating a Proxy type
class that I transfer down to the applet.  Would this be a better solution?
Any other ideas about how to transfer over a persistent object via
serialization but without killing the network traffic to the end client
where the applet will receive it?

Many thanks in advance,

J.D.

--
J.D. Fagan
2Bridge Software

2. ODBC Drivers Gone?!

3. Applet Servlet Communication in NES using Object Serialization

4. JDBC drivers

5. Storing Objects - Serialization vs. Db

6. Capturing inefficient SQLs

7. Object Serialization with JDBC

8. calculating percentages.

9. Serialization and database access

10. Looking for database serialization/diff tool

11. Serialization to a relational database

12. Help ! ODBC Error Code = 4001 (Serialization Error

13. Help: Serialization Error