Thread View: borland.public.jbuilder.java.api
3 messages
3 total messages
Started by andy
Wed, 09 Oct 2002 09:15
how to convert from datatype String into datatype Blob
Author: andy
Date: Wed, 09 Oct 2002 09:15
Date: Wed, 09 Oct 2002 09:15
7 lines
1046 bytes
1046 bytes
hai, can convert from String into a Blob variable ? TIA, andy
Re: how to convert from datatype String into datatype Blob
Author: Tor Iver Wilhelmsen (TeamB)
Date: Wed, 09 Oct 2002 12:26
Date: Wed, 09 Oct 2002 12:26
6 lines
1119 bytes
1119 bytes
"andy" <andy@cpssoft.com> writes:
> can convert from String into a Blob variable ?
Try getting a byte[] by calling getBytes("<encodingname>") and use
that.
Re: how to convert from datatype String into datatype Blob
Author: Shankar Unni
Date: Wed, 09 Oct 2002 17:10
Date: Wed, 09 Oct 2002 17:10
31 lines
2302 bytes
2302 bytes
On 10/9/2002 2:15 AM, andy wrote:
> can convert from String into a Blob variable ?
This is for what? For passing to PreparedStatement.setBlob()?
Creating Blob objects is _completely_ implementation-defined. Many JDBC
implementations don't support this at all (e.g. mm.mysql), or make it
very convoluted (e.g. Oracle, where you have to first create a BLOB
object in the DB, and then map it to memory).
What you *can* do with the String is one of the following (and even with
these, there are implementation issues):
1. PreparedStatement.setBytes(column, string.getBytes())
2. PreparedStatement.setBinaryStream(column,
new ByteArrayInputStream(string.getBytes());
3. Use a platform-specific sequence to get a Blob object (read your
particular JDBC driver's documentation) and call
PreparedStatement.setBlob().
For instance,
1. works in Oracle for strings upto 32000 bytes, and in MySQL for all
strings.
2. works in Oracle as long as you are using the thick driver, or the
thin driver version later than 9.2.1.
3. doesn't work at all for MySQL, and is extremely convoluted for Oracle.
--
Shankar.
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads