Re: Troubleshooting utf8 text SQL generation
Re: Troubleshooting utf8 text SQL generation
- Subject: Re: Troubleshooting utf8 text SQL generation
- From: Kieran Kelleher <email@hidden>
- Date: Fri, 13 Apr 2007 23:09:17 -0400
Ah yes, thanks for the pointer Peter. It is String C .... C =
setCharacterStream for java.sql.PreparedStatement. It just seems
obvious at the time to pick the entry having UTF8 character stream in
the description. And the query is actually faster now and does not
hit the slow query log anymore.
Thanks, Kieran
The value type also specifies which JDBC methods are used to send and
retrieve the data to and from the database. These value types affect
which method the java.sql.PreparedStatement object uses to transfer
text data between the database and the JDBC adaptor. For attributes
with a value class of String, the following value types are defined:
<none>—uses setString if the text is less than the database’s
advertised maximum varchar length and setCharacterStream if it is too
large. If the database fails to advertise a maximum length, the
default is 256 characters.
S—uses setString regardless of the text’s length.
C—uses setCharacterString regardless of the text’s length.
E—converts the text into raw UTF-8 bytes and then uses
setBinaryStream to save them in a binary-typed column in the database.
c—tells the adaptor to generate SQL using RTRIM to strip off
all trailing spaces.
On Apr 13, 2007, at 8:16 PM, Peter Vandoros wrote:
Hi Kieran,
If you are using TEXT and specified the charset to utf8, then you
don't need to specify the valueType of E. Value type E is for
databases that don't support UTF8 natively. If you change the
valueType to something like S of c (not sure if this one is
correct, check the documentation), then WO won't try to write/read
the data as binary and convert it to a UTF8 String but instead it
will write/read the data as a UTF8 String directly. This should
solve your issue.
Keep in mind that you need to make sure that your JDBC URL is set
to use that charset and unicode. See WebObjects wiki for more
details on using MySQL with WO.
Regards
Peter
On 14/04/2007, at 4:58 AM, Kieran Kelleher wrote:
Hi guys, thanks for replies. The field is a type TEXT, so it does
support encoding.... by chance I noticed the SQL was casting my
search terms to _binary and that seems wrong.
On Apr 13, 2007, at 7:44 AM, Dev WO wrote:
Hello Kieran,
Someone will probably come up with an alternative, but I've never
been to be able to make blob work the way I wanted with UTF-8. I
had to convert my blob to mediumtext.
As far as I know (but I'm not a db expert;)) blob can't have an
encoding like a mediumtext for example.
Xavier
I have a text blob attribute defined as
External Type : TEXT
Data Type : UTF Character Stream - String E
EOF is treating it as binary in the SQL generation, so I get this:
... UPPER(T3.textobject) LIKE UPPER(_binary'%argentina%') ...
instead of this which is what I should expect??
... UPPER(T3.textobject) LIKE UPPER(_utf8'%argentina%') ...
I am using MySQL. My connection string is:
jdbc:mysql://localhost/omega?
useUnicode=true&characterEncoding=UTF-8
and the table is defined as:
CREATE TABLE `textblob` (
`oid` int(11) NOT NULL,
`textobject` text,
PRIMARY KEY (`oid`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
Am I correct in thinking I should not be getting _binary before
the search term?
-Kieran
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
40anazys.com
This email sent to email@hidden
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
40etechgroup.com.au
This email sent to email@hidden
--
This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
40mac.com
This email sent to email@hidden
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden