-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: MySQL Blob to SQL Server Image conversion
PostPosted: Mon Jun 12, 2006 8:08 am 
Newbie

Joined: Mon Jun 12, 2006 7:47 am
Posts: 1
Hi, i'm using Hibernate 3.1 with SQL Server 2005.
i am in trouble. i create a userType for modify the blobType cause i use 3 database and i have to switch these dbs. the code in the nullSafeSet method for mysql is this:

java.sql.Blob blob = Hibernate.createBlob((InputStream)value);
ps.setBlob(index, blob);


where "value" is my object (a binaryStream).
And this code is ok.

With oracle i inserted the code of Scott Miller for problems with oracle/blog
but also this code is ok.

Now, when i have to use SQL Server i have error in code. This is my code:

try
{

ByteArrayOutputStream byteStream = new ByteArrayOutputStream();
ObjectOutputStream os = new ObjectOutputStream(byteStream);
os.flush();
os.writeObject(value);
os.flush();
os.close();
//retrieves byte array
byte[] valueByte = byteStream.toByteArray();

SQLServerConnection ssconn = (SQLServerConnection) ps.getConnection();

//SQLServerBlob (SQLServerConnection, byte[])
SQLServerBlob blob = new SQLServerBlob(ssconn, valueByte);
ps.setBlob(index, blob);
}catch(IOException e){}

But doesn't work!


WARN JDBCExceptionReporter - SQL Error: 0, SQLState: null
ERROR AbstractFlushingEventListener - Could not synchronize database state with session

please help me write the nullSafeSet method for write an Object in a column "Image" of my db!


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.