Subject Re: [ib-support] Storing SJIS characters in Interbase via JDBC?
Author Helen Borrie
At 08:06 PM 29-07-02 +0000, L. Cruz wrote:
>Greetings. In Interbase 6.X, I have created a database and table that
>both use the SJIS_0208 character set as the default character set.
>Metadata is below.
>
>CREATE DATABASE 'sjis.gdb' DEFAULT CHARACTER SET SJIS_0208 */
>
>CREATE TABLE "FOO"
>(
> "BAR" VARCHAR(30) CHARACTER SET SJIS_0208,
> "BARBLOB" BLOB SUB_TYPE TEXT SEGMENT SIZE 80 CHARACTER SET SJIS_0208
>);
>
>I am trying to insert SJIS characters via JDBC; unfortunately, the
>characters do not seem to be stored properly in the database when they
>are inserted. I am using two JSP pages and one Java class to test the
>process. The first page is a form that submits to the second page.
>The second page first displays the form text it received, then inserts
>into the database via my Java class, and then uses my Java class to
>select the rows from the database and display them.
>
>The SJIS characters entered into the form are rendered correctly by
>the second JSP page. However, they do not seem to survive the
>insertion and retrieval from the database. All I get is a question
>mark or two for each SJIS character.
>
>Do you have to specify the character set in JDBC to be SJIS? If so,
>how? Do I need a specialized build of Interbase?

No, you don't. As long as your column is specified to be SJIS, the server
knows to handle the data as such.

Specifying the charset for the column is only half of the journey. Your
problem is a client one. Either

- the client has to connect with the character set specified as SJIS (the
default is NONE) using the database parameter block (DPB) item
isc_dpb_lctype; or
- the character set has to be specified in the data package, which depends
on whether you are passing your string to a blob or to a character type, viz.

At the API, the character set can be specified in the blob descriptor by
various calls (in the case of a text blob) or as a marker in your SQL
preceding a string destined for a "non-NONE" character set column.

In the case of the DPB - and probably the blob descriptor as well - the
JDBC driver will have encapsulated the API function call via a
function. In the case of SQL, you would prefix the string with _SJIS_0208,
i.e. the formal character set name preceded by an underscore, e.g.

insert into aTable(idcol, stringcol)
values(99, _SJIS_0208 'This is your string')

For more info about the JDBC function you need for your database connection
or blob, I recommend you join the Firebird-Java list and raise a question
there. To subscribe, go to
http://www.yahoogroups.com/community/firebird-java

cheers,
heLen


All for Open and Open for All
Firebird Open SQL Database · http://firebirdsql.org ·
http://users.tpg.com.au/helebor/
______________________________________________________________________