powered by simpleCommunicator - 2.0.61     © 2026 Programmizd 02
Целевая тема:
Создать новую тему:
Автор:
Закрыть
Цитировать
Форумы / Java [игнор отключен] [закрыт для гостей] / Oracle, CLOB и русские буквы
2 сообщений из 2, страница 1 из 1
Oracle, CLOB и русские буквы
    #33096003
Igor-65
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Гость
Добрый день

oracle : 8.1.7, клиент 9.2
jdk 1.5

клиент - WinXP.

Задача: русский текст загнать в clob

пишу:
Код: plaintext
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
14.
15.
16.
17.
18.
19.
20.
21.
22.
23.
24.
25.
26.
27.
28.
        Connection conn = DriverManager.getConnection(
                            url,
                            username, pwd);

       String sqlInsert = "insert into tbl_clob (id,my_clob) values(?,?)";

       PreparedStatement stmt = connect.prepareStatement(sqlInsert);

       stmt.setLong( 1 , 1 );

       CLOB newClob = oracle.sql.CLOB.createTemporary(connect, false, 
               oracle.sql.CLOB.DURATION_SESSION);

       String str ="qwerty"; // эту строку занесем в CLOB

       newClob.open(CLOB.MODE_READWRITE);
       Writer tempClobWriter = newClob.getCharacterOutputStream();
       tempClobWriter.write(str);
       tempClobWriter.flush();
       tempClobWriter.close();
       
       newClob.close();
       stmt.setClob( 2 ,newClob);

        int  rowcnt = stmt.executeUpdate();

       newClob.freeTemporary();
       newClob =  null ;
       connect.commit();
этот кусок работает. Стоит заменить строку "qwerty" на что-то с русскими буквами ("ЙЦУКЕН")- работать перестает.
При выполнении tempClobWriter.flush();
выдает:
java.io.IOException: Исключение ввода/вывода: End of TNS data channel
at oracle.jdbc.dbaccess.DBError.SQLToIOException(DBError.java:716)

Что делать ? Куда копать ?

(никаких индексов и констрейнтов в тестовой таблице нет.)
...
Рейтинг: 0 / 0
Oracle, CLOB и русские буквы
    #33097037
Фотография Denis Popov
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Участник
Попробуй так:

Код: plaintext
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
14.
15.
16.
17.
18.
19.
20.
21.
22.
23.
24.
25.
Connection con =  null ;
CLOB clob =  null ;
Statement st =  null ;
PreparedStatement pst =  null ;
 try  {
   Class .forName("oracle.jdbc.OracleDriver");
  con = DriverManager.getConnection(SERVER, USERNAME, PASSWORD);
  st = con.createStatement();
   try  {
    st.execute("drop table test_lob");
  }  catch  (SQLException e) { }
  st.execute("create table test_lob (cdata clob)");
  pst = con.prepareStatement("insert into test_lob (cdata) values (?)");
  clob = CLOB.createTemporary(con, true, CLOB.DURATION_SESSION);
   char [] body = "ЙЦУКЕ".toCharArray();
  clob.putChars( 1 , body);
  pst.setClob( 1 , clob);
  pst.execute();
}  finally  {
   if  (clob !=  null ) {
    CLOB.freeTemporary(clob);
  }
   if  (st !=  null ) { st.close(); }
   if  (pst !=  null ) { pst.close(); }
   if  (con !=  null ) { con.close(); }
}
...
Рейтинг: 0 / 0
2 сообщений из 2, страница 1 из 1
Форумы / Java [игнор отключен] [закрыт для гостей] / Oracle, CLOB и русские буквы
Найденые пользователи ...
Разблокировать пользователей ...
Читали форум (0):
Пользователи онлайн (0):
x
x
Закрыть


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