MySQL jdbc, cannot insert object
Hi all,
I am having troubles inserting an object into a MySQL database. I tried to insert it with both the BinaryInputStream and setObject functions, but to no avail. If I run the query in mysql-query-browser, it runs fine (as long as I have nulled out the ** INPUT STREAM ** from doing a PreparedStatement.toString(). I have googled my exception line numbers but nothing turns up. I don't believe it is bad SQL syntax as I can run it in the query-browser tool, so I am stumped as to where else I can look.
Here is the code I am using:
//st.setObject(j, value);
ByteArrayInputStream input_stream = io.serialize(value);
st.setBinaryStream(j, input_stream, input_stream.available());
// serialize an object to a string which can be stored into a mysql database
publicstatic ByteArrayInputStream serialize(Object input_object)
{
try
{
ByteArrayOutputStream os =new ByteArrayOutputStream();
ObjectOutput object_output =new ObjectOutputStream(os);
object_output.writeObject(input_object);
return(new ByteArrayInputStream(os.toByteArray()));
//return(os.toString());
}
catch(IOException e)
{
e.printStackTrace();
return(null);
}
}
statement:com.mysql.jdbc.PreparedStatement@5f1eb199: insert into web_application.session (remote_address,update_time,user,browser_name,history,session_id,start_time) values('127.0.0.1','2007-06-24 10:14:34',null,'Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.8.1.4) Gecko/20070601 Firefox/2.0.0.4',** STREAM DATA **,'FCBB07D8B524044B79F546337512DAA1','2007-06-24 10:14:34')
createSQLException.com.mysql.jdbc.SQLError=SQLError.java,957
checkErrorPacket.com.mysql.jdbc.MysqlIO=MysqlIO.java,2938
sendCommand.com.mysql.jdbc.MysqlIO=MysqlIO.java,1601
sqlQueryDirect.com.mysql.jdbc.MysqlIO=MysqlIO.java,1710
execSQL.com.mysql.jdbc.Connection=Connection.java,2436
executeInternal.com.mysql.jdbc.PreparedStatement=PreparedStatement.java,1402
executeUpdate.com.mysql.jdbc.PreparedStatement=PreparedStatement.java,1593
insert.io.database=database.java,206
insert.application.table=table.java,131
insert.application.session=session.java,123
<init>.application.session=session.java,50

