tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "John Gregg" <john.gr...@techarch.com>
Subject RE: Storing Java Objects in SQL
Date Wed, 12 Jun 2002 18:18:35 GMT
It's not so simple.  setObject() only works if the object is an instance of
a java class that maps nicely to whatever SQL type is the type of the column
you're trying to set (e.g., java.lang.String --> VARCHAR).  You can't just
call setObject() on any java object and expect it to work.  Unless you
really want to store serialized java objects as binary data, you should
search the internet for "object-relational mapping" to find out a little
about how to attack this problem.  Lately I've been doing something like
this: http://www.martinfowler.com/isa/OR-mapping.html

john


-----Original Message-----
From:
tomcat-user-return-22382-john.gregg=techarch.com@jakarta.apache.org
[mailto:tomcat-user-return-22382-john.gregg=techarch.com@jakarta.apache.
org]On Behalf Of Paul Kofon
Sent: Wednesday, June 12, 2002 12:39 PM
To: tomcat-user@jakarta.apache.org
Subject: Storing Java Objects in SQL


Hi all,
I'm trying to store objects (instances) of a class in Microsoft SQL Server
2K using the Microsoft-provided JDBC driver, but I've been without any luck
thus far.
I've used the setObject() method in the PreparedStatement class and set my
target sql type to "BINARY", yet it doesn't work, I keep getting an
SQLException. A look at the driver documentation shows that this method is
supported while set/getBlob() aren't.
Is what I'm trying to achieve impossible or am I doing something wrong?
I could serialize the objects to disk but I'll have files lying all over the
place - storing them in the database per user would be much neater.
I need help fast! I'm Thanks.

Regards,

Paul


--
To unsubscribe, e-mail:   <mailto:tomcat-user-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:tomcat-user-help@jakarta.apache.org>


Mime
View raw message