大家好,sybase中txt类型乱码的问题!谢谢
<P>大家好,我有个问题要请教,我用createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,ResultSet.CONCUR_READ_ONLY);然后读取数据集的时候sybase中的txt值是乱码,string值没问题,如果直接createStatement();则都无问题,现在我要取得记录数要用rs.last();,而rs.last(); 就要用第一种!怎么解决这个乱码的问题啊,谢谢了!</P> 奇怪。能不能提供代码片段,以及数据库字符集设置? <P>数据库字符集是cp936</P><P>ResultSet rsPNode = sybconnId.Query(sql);</P>
<P>System.out.println(rsPNode.getString("p_txt"));</P>
<P>public ResultSet Query(String sql) {<BR> ResultSet rs = null;<BR> try {<BR> conn = getConnection();<BR> if (conn == null)<BR> return null;<BR> stmt = conn.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,ResultSet.CONCUR_READ_ONLY);///就是这一行的变动<BR> rs = stmt.executeQuery(sql);<BR> System.out.println("........... Resulset get success");<BR> }<BR> catch (SQLException e) {<BR> System.err.println("dbBean:executeQuery():" + e.getMessage());<BR> }<BR> return rs;<BR>}</P>
<P>而且无论用哪种方式都不成|</P>
<P>System.out.println(rsPNode.getString("p_txt"));<BR>System.out.println(rsPNode.getString("p_txt").getBytes());//<BR>System.out.println(rsPNode.getString("p_txt").getBytes("GB2312"));//3<BR> System.out.println(rsPNode.getString("p_txt").getBytes("ISO8859_1"));//4 <BR>System.out.println(new String(rsPNode.getString("p_txt").getBytes()));//5 <BR>System.out.println(new String(rsPNode.getString("p_txt").getBytes(),"GB2312"));//6 <BR>System.out.println(new String(rsPNode.getString("p_txt").getBytes(),"ISO8859_1"));//7 <BR>System.out.println(new String(rsPNode.getString("p_txt").getBytes("GB2312")));//8 <BR>System.out.println(new String(rsPNode.getString("p_txt").getBytes("GB2312"),"GB2312"));//9 <BR>System.out.println(new String(rsPNode.getString("p_txt").getBytes("GB2312"),"ISO8859_1"));//10 <BR>System.out.println(new String(rsPNode.getString("p_txt").getBytes("ISO8859_1")));//11 <BR>System.out.println(new String(rsPNode.getString("p_txt").getBytes("ISO8859_1"),"GB2312"));//12 <BR>System.out.println(new String(rsPNode.getString("p_txt").getBytes("ISO8859_1"),"ISO8859_1"));//13 </P>
<P>将编码改成cp936也还是不行</P>
<P> System.out.println(rsPNode.getString("p_txt").getBytes("cp936"));</P>
<P>…………</P>
页:
[1]