Hi, Could you post any example of proper get/set methods for LONG VARCHAR UNICODE field in Java? As an input and output of method I need String in UTF-8 with content of the db field (or the new field value).
I tried to set and get CLOB field (LONG VARCHAR UNICODE) via JDBC driver. The field and the whole database is in UNICODE mode. I use JBoss 3.02 application server and 7.3.00.28a JDBC driver. _________________________________________ Getting Unicode CLOB field: _________________________________________ In methods of my EJB I have problems with getting Unicode data to String variable in UTF-8. Character stream for ASCII characters have one null byte of 0x00, which ends String variable. Only national characters outside of ASCII table have seconf byte not null. How to convert ASCII stream from Unicode to UTF-8 and from UTF-8 to Unicode? ResultSet lrs; Clob clob = lrs.getClob(CLOB_COLUMN); long len = clob.length(); int ilen = new Long(len).intValue(); I tried the following methods to get String from LONG VARCHAR UNICODE field: 1.) String doc = clob.getSubString(1, ilen); 2.) InputStream reader = clob.getAsciiStream(); InputStreamReader isr = new InputStreamReader(reader, "UTF8"); byte[] cs = new byte[ilen]; reader.read(cs, 0, ilen); String doc = new String(cs, "UTF16"); 3.) java.io.Reader reader = clob.getCharacterStream(); char[] cs = new char[ilen]; reader.read(cs, 0, ilen); String doc = new String(cs, "UTF16"); First occurence of 0x00 character ends doc String. _________________________________________ How to insert UTF-8 String in Unicode CLOB field? _________________________________________ When I use in get method: ResultSet lrs ... String doc = lrs.getString(CLOB_COLUMN); and in set method: String clob_text; clob_text = .... here comes large UTF-8 text from input PreparedStatement lstm; ... lstmt.setString(CLOB_COLUMN, clob_text); >>> .. all works perfectly as on the normal String field!!! <<< I can read/store in the database large unicode data. I tried text longer than 1 MB and it was working without any problem. CLOB_COLUMN maps for column of type LONG VARCHAR UNICODE. Is this behaviour correct? Does SapDB driver convert between String and LONG VARCHAR UNICODE on the fly? Regards, Radoslaw Sliwinski MAD Multimedia Art Design _______________________________________________ sapdb.general mailing list [EMAIL PROTECTED] http://listserv.sap.com/mailman/listinfo/sapdb.general
