Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.misc -> Re: JDBC output coming out as hex
In article <v3c7rortcb4f58_at_corp.supernews.com>,
Anurag Varma <avdbi_at_hotmail.com> wrote:
>Never heard this one.
>As a start ... Can you post a simple code and the resultset that is being fetched?
>
>Anurag
>
>"Cheng-Jih Chen" <postmaster_at_cjc.org> wrote in message news:v3b062klb8601a_at_news.supernews.com...
>>
>> The server is running 9.2.0.2 on Windows, and we're connecting using
>> the JDBC thin client. The problem we're seeing is that SELECT output
>> from JDBC is coming out as hex; accessing the same data using SQLPlus
>> returns as regular characters.
>>
>> The same JDBC connecting to a 9.2.0.2 server on Solaris returns the
>> data correctly.
>>
>> NLS settings between the two servers are identical.
>>
>> Does anyone have any suggestions? Thanks.
Here's the reply my developer on the problem:
We are using the Oracle Object tables and these Objects are retrieved using JPublisher generated Java Server Objects. Through these object if we retrieve the java.lang.String it is returned as Hexadecimal Number (instead of characters).
Example:
public String getUserName()
{
...
...
String sqlStr.append("select value(u) from mms_user_tbl u Where rownum < 2");
OracleConnection con = (OracleConnection)server.getConnection(); String userName = null;
try { OracleStatement stmt = (OracleStatement)con.createStatement(); OracleResultSet rs = (OracleResultSet)stmt.executeQuery(sqlStr);
//MmsUserObj is generated by Oracle's JPublisher
MmsUserObj userObj;
if (rs!=null) { while(rs.next()) { userObj = (MmsUserObj)rs.getORAData(1,MmsUserObj.getORADataFactory()); = userObj.get
d = oracleObj.getUserName();
// The d.stringValue() returns equivalent hexadecimal representation
of user_name (This happens only on Windows Version Oracle Database)
//say user name is: wbuser, then d.stringValue() returns 0x776275736572.
if (d != null) userName = d.stringValue();
} } rs.close(); stmt.close(); } finally { con.close(); } return userName;
Note: The above Java code works fine with Oracle 9.2.0.1 on Sun Solaris.
The database object and table looks as follow:
CREATE OR REPLACE TYPE MMS_USER_OBJ AS OBJECT (
end_date DATE, start_date DATE, enabled NUMBER(1), password RAW(64), user_name VARCHAR2(255), user_id NUMBER(30), user_upi_number VARCHAR2(255), user_long_name VARCHAR2(255));
CREATE TABLE MMS_USER_TBL OF MMS_USER_OBJ;
The operating System: Windows 2000
Oracle Version: Oracle 9.2.0.1
Received on Thu Jan 30 2003 - 16:37:30 CST