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: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]. org]On Behalf Of Paul Kofon Sent: Wednesday, June 12, 2002 12:39 PM To: [EMAIL PROTECTED] 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:[EMAIL PROTECTED]> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>
