aspose file tools*
The moose likes JDBC and the fly likes tomcat show string gotten from nested table  as Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC
Bookmark "tomcat show string gotten from nested table  as "???" " Watch "tomcat show string gotten from nested table  as "???" " New topic
Author

tomcat show string gotten from nested table as "???"

feihong wu
Greenhorn

Joined: Oct 28, 2004
Posts: 3
hi,there

since nobody in Servlet body answer me for two days,
I had to repost the question here.coz I dont know whether the problem
lies in tomcat/jsp or jdbc or oracle.seems it's a chanlleging problem and
all tangle up.

I implemented a java class MyTest to retrive a field in a oracle table Test.The specialty is ,the field is a nested table of varchar2(8).I used thin oracle JDBC and the program runs normally.but when I tried to call
the MyTest in a Jsp/Jservlet to show the string in the nested table,I only
got "???" printed in the screen.what's the matter?does anyone come up with
such case before?thanks a great.

some notes
a.the string is properly showed if gotten from a common varchar2(8) field of oracle table.

b.I tried the combination of class12.jar+nls_charset12.jar and
ojdbc14.jar+orai18n.jar,but without any cheerful change.

c.I tried to change the charset in the Jsp/Jservlet...her I cant say I did it in a comprehensive way.but failed too.

d.all the record in the nested table are english string.

e.tomcat 5.0,oracle 10.0g,jdk1.4.2

attached with the oracle table Test and part of the code of MyTest.hopefully it's simple enough.

the table test has only one column which is a nested table of varchar(8) like
--------------------------------------------------------
create type string_tab varchar2(8);
create table test (attr string_tab) nested table attr stored as attr_tab;
--------------------------------------------------------

and java class mytest is like:
-------------------------------------------------------
class mytest{
....
public String get(){
String ret="";
......\\connect to the database
pstmt = conn.prepareStatement(
"select attr from test");
rs = pstmt.executeQuery();
if (rs.next()) {
s = ( (OracleResultSet) rs).getARRAY("attr1");
ResultSet r = s.getResultSet();
if(r.next()) {
ret = r.getString(2);
}
r.close();
}
rs.close();
pstmt.close();
}
\\disconnect the database
return ret;
}
feihong wu
Greenhorn

Joined: Oct 28, 2004
Posts: 3
haha,I've straighten it out.
all is ok just change the data type varchar to nvarchar,
which is national charset.hopefully someone who come up
with such problem will benefit from my answer.
Jeanne Boyarsky
author & internet detective
Marshal

Joined: May 26, 2003
Posts: 30918
    
158

Feihong,
Thanks for posting the solution for others!


[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: tomcat show string gotten from nested table as "???"