Hi Roger,
Actually I was able to store the blob in the MySql database using
torque, since torque already uses prepared statements to do
insert/updates. The problem I as having was performing a select. I think
it would be at least mildly difficult to modify torque so that it used
prepared statements in general for selects, since SQL selects are all
prepared dynamically.
There might be an argument for switching torque over to prepared
statements for selects that would be interesting to hear.
Anyhow I did try selecting using a prepared statement, and that also
failed. I was using the following code:
DBConnection db = Torque.getConnection( x_crit.getDbName() );
Connection connection = db.getConnection();
PreparedStatement pstmt = connection.prepareStatement("SELECT * FROM URI
where KEY_ID = ?");
pstmt.setBytes(1, p_key_id);
ResultSet rs = pstmt.executeQuery() ;
rs.first() ;
o_cat.info("!!!!!!!!!!!!!!!!!!!!!!" + rs.getString(1)+"!!!!!!!!!!!!!!!!!");
However I still seemed to be unable to retrieve the blob with this
select. My intention was to store a public key as binary data and then
retrieve the correct row by selecting against the binary data itself.
Strange I know, but necessary for my application.
CHEERS> SAM
Roger I Martin PhD wrote:
>Hi,
>
>
>
>>A few days ago when I was trying to store a blob in a MySQL
>>database I...
>>
>>
>
>I am not yet applying Torque so I don't know if what I am doing is useful.
>I've been blobbing data into MySQL for quite sometime with my own home grown
>code and I don't have to deal with escape characters at all. It seems
>escaping would hinder speed. I simply implemented the Blob interface
>http://java.sun.com/j2se/1.4/docs/api/java/sql/Blob.html, shoving the data
>into it and then use a PreparedStatement
>http://java.sun.com/j2se/1.4/docs/api/java/sql/PreparedStatement.html and
>wham the data is in the database without escapes. When I get a Blob back,
>it comes back in the drivers Blob implementation. Very fast. Is there a
>need for such code in Torque?
>
>--Roger
>
>
>
>
>
>
--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>