Гость
Целевая тема:
Создать новую тему:
Автор:
Форумы / Sybase ASA, ASE, IQ [игнор отключен] [закрыт для гостей] / Unicode conversion problem / 15 сообщений из 15, страница 1 из 1
02.08.2007, 16:22
    #34701848
rulerm
Гость
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Unicode conversion problem
Hello

Please excuse me that I'm not using russian. My russian is very bad. I can read what is written but it's really hard for me to write in your language.

I have the following problem:
I'm using ASE 15.0
In my database I have more that 1000 java class, many sqlj procedures and functions.
In some of them I have to send warning messages to my clients. To do that I'm using following code:

throw new Exception("текст");

or

PreparedStatement pstmt = con.prepareStatement("raiserror 99999 'текст' ");
pstmt.execute();


The message is sended to the client but the text is incorrect.
I getting incorrect text no matter from where I execute my sqlj procedure (Iteractive SQL, MFC program).

Server's default character set is Cp1251.
The unicode conversion between Java and ASE is enabled. Even if it is not enabled the text is incorrect.

If my message is from 3 symbols I get 6 symbols as a result.

I think that the server is making some conversion but it is not doing it right.

Have ever faced with this problem? Is there an other way to send warning message to my client application
...
Рейтинг: 0 / 0
02.08.2007, 16:51
    #34702019
MasterZiv
Участник
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Unicode conversion problem
Переведу что ли ...

rulermHello

У меня следующая проблема. Я использую ASE 15.0.
В моей базе данных у меня более 1000 Java-классов, много SQLJ-процедур и функций.
В некоторых из них мне приходится посылать предупреждения клиентам.
Я это делаю так:

Код: plaintext
1.
throw new Exception("текст");

или

Код: plaintext
1.
2.
PreparedStatement pstmt = con.prepareStatement("raiserror 99999 'текст' ");
pstmt.execute();

Сообщение посылается клиенту, но текст сообщения неправильный.
При этом не имеет значения откуда я выполняю SQLJ-процедуру (Iteractive SQL, MFC program),
я получаю сообщение неправильно.

На сервере default character set - Cp1251.
Unicode conversion между Java и ASE включён.
Но даже если его отключить, текст все равно неверный.

Если напр. мое сообщение из трех символов, я получаю на клиенте 6 символов.

Я думаю, что сервет выполняет какие-то преобразования, но делает это неправильно.

Вы сталкивались с такой проблемой когда-нибудь ?

Есть ли какой-то другой путь послать сообщение клиенту ?
...
Рейтинг: 0 / 0
02.08.2007, 17:05
    #34702094
Stoyan Minchev
Гость
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Unicode conversion problem
Спосибо MasterZiv :)
...
Рейтинг: 0 / 0
02.08.2007, 17:39
    #34702228
White Owl
Участник
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Unicode conversion problem
rulermIf my message is from 3 symbols I get 6 symbols as a result.most likely, your client receive string in UTF-16. ...or client (I suspect it is written on Java itself) does it's own conversion of string to UTF-16 but visual control is not ready to handle it.
Try to connect to DB from the most simplistic tool you can find (I would go with my own ODBC client for example) and see that exactly comes to your application from driver. At least you would be able to tell is incorrect string conversion happens in the db->driver or driver->application or is it pure application problem.

Your turn MasterZiv :)
...
Рейтинг: 0 / 0
02.08.2007, 18:09
    #34702346
Stoyan Minchev
Гость
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Unicode conversion problem
My client is MFC program. I'm using ODBC.

When I execute my sqlj procedure within isql or Interactive SQL I get the same rubbish.
In this case the only driver involved is the native jdbc driver. In the ASE 15.0 documentation is written that the conversion between Unicode and the default character set (in my case Cp1251) inside the server is made automatically.

And It's true when I'm inserting some text in a table using PreparedStatement from sqlj procedure as follows:

PreparedStatement pstmt = con.prepareStatement("insert into tbl(text) values(?)");
pstmt.setString(1,"Стоян");
pstmt.executeUpdate();

the inserted text is correct.

It is interesting that when I'm using

PreparedStatement pstmt = con.prepareStatement("insert into tbl(text) values('Стоян')");
pstmt.executeUpdate();

Rubbish is inserted.
...
Рейтинг: 0 / 0
02.08.2007, 18:44
    #34702454
just me
Гость
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Unicode conversion problem
Execute once and look at output:

select * from syscharsets where id=190
go
sp_configure "enable unicode conversion"
go

Execute in "good" and "bad" connection and compare results:

select @@client_csid,@@char_convert
go
...
Рейтинг: 0 / 0
02.08.2007, 18:57
    #34702490
Stoyan Minchev
Гость
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Unicode conversion problem
select * from syscharsets where id=190
go
nothing returned.
-----------------------

sp_configure "enable unicode conversion"
go
Parameter Name: enable unicode conversions
Default: 1
Memory Used: 0
Config Value: 1
Run Value:1
Unit: switch
Type: dynamic
----------------------------------
select @@client_csid,@@char_convert
go

@@client_csid = 53
@@char_convert = 0
...
Рейтинг: 0 / 0
02.08.2007, 19:07
    #34702505
MasterZiv
Участник
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Unicode conversion problem
White Owl пишет:

> Your turn MasterZiv :)

I haven't even a foggiest idea.
Posted via ActualForum NNTP Server 1.4
...
Рейтинг: 0 / 0
02.08.2007, 19:25
    #34702538
just me
Гость
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Unicode conversion problem
You do not have utf8 installed on this server:

charset.exe -Usa -P... -Sserver_name binary.srt utf8

Your client charset is cp1251 and server does not do any conversion inside it.
You can try to connect to server with client charset = utf8 and check results.
...
Рейтинг: 0 / 0
02.08.2007, 20:13
    #34702597
Stoyan Minchev
Гость
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Unicode conversion problem
Thank about the advice. Tommorow at work I'll try it and I'll tell the results :)
...
Рейтинг: 0 / 0
02.08.2007, 20:55
    #34702652
just me
Гость
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Unicode conversion problem
just meYou do not have utf8 installed on this server:

charset.exe -Usa -P... -Sserver_name binary.srt utf8

Your client charset is cp1251 and server does not do any conversion inside it.
You can try to connect to server with client charset = utf8 and check results.

First step is not mandatory.
You can try to change only client charset to utf8.
...
Рейтинг: 0 / 0
02.08.2007, 23:07
    #34702787
Stoyan Minchev
Гость
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Unicode conversion problem
It's a little bit complicated. My client application is now working with ASA 9.0. I have to make it to work also with ASE 15.0 If I change the client's character set I'll have a problem with my ASA 9.0. And my client application is MFC program. I don't know if I can change the character set.

Before a couple of days I set the jdbc driver's option CHARSET = "utf8" and there was no effect.
...
Рейтинг: 0 / 0
02.08.2007, 23:15
    #34702798
White Owl
Участник
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Unicode conversion problem
Stoyan MinchevBefore a couple of days I set the jdbc driver's option CHARSET = "utf8" and there was no effect.Remove quotes around charset name. Define it simply: UID=...;PWD=...;CHARSET=utf8 ;someotherkey=... and that should do the trick
...
Рейтинг: 0 / 0
03.08.2007, 10:43
    #34703333
Stoyan Minchev
Гость
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Unicode conversion problem
I didn't write it correctly

props.put("user", ase_db_conf.getUser());
props.put("password", ase_db_conf.getPass());
props.put("CHARSET","utf-8");


this is the way i tried to change the driver's charset.

As I said before I can't change the client's character set. I installed utf8 and there is no possitive effect.
But why utf8? Java is using utf16 isn't it?
...
Рейтинг: 0 / 0
03.08.2007, 17:34
    #34704814
White Owl
Участник
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Unicode conversion problem
Stoyan MinchevBut why utf8? Java is using utf16 isn't it?I am not sure about Java, but ASA9 for example does not work with UTF-16 at all. It has only UTF-8 and its alias for charset parameter is utf8 .
...
Рейтинг: 0 / 0
Форумы / Sybase ASA, ASE, IQ [игнор отключен] [закрыт для гостей] / Unicode conversion problem / 15 сообщений из 15, страница 1 из 1
Найденые пользователи ...
Разблокировать пользователей ...
Читали форум (0):
Пользователи онлайн (0):
x
x
Закрыть


Просмотр
0 / 0
Close
Debug Console [Select Text]