| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 2212 人关注过本帖
标题:乱码问题(找了很多资料也没有办法)
取消只看楼主 加入收藏
laoxie3
Rank: 1
等 级:新手上路
帖 子:6
专家分:0
注 册:2006-1-25
收藏
 问题点数:0 回复次数:1 
乱码问题(找了很多资料也没有办法)

<%@ page contentType="text/html;charset=GBK" %>
<%@ page import="java.*" %>
<%@ page import="java.util.*" %>
<%@ page import="javax.sql.*" %>
<%@ page import="java.sql.*" %>

<head>

<title>无标题文档</title>
<style type="text/css">
<!--
.STYLE1 {color: #FF8040}
-->
</style>
</head>

<body>
<%

Class.forName("oracle.jdbc.driver.OracleDriver").newInstance();
String url="jdbc:oracle:thin:@127.0.0.1:1521:ctais";
String user="ctais2";
String password="oracle";
Connection conn= DriverManager.getConnection(url,user,password);
Statement stmt = conn.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,ResultSet.CONCUR_UPDATABLE);;

String sqla=" select * from dm_xhlx ";
ResultSet rs1 = stmt.executeQuery(sqla);
out.println(rs1);
String src = "12345上解销号ABCDE";
%>


<form id="form1" name="form1" method="post" action="">
<table border="2" bordercolor="#000033">
<tr>

<td> <%=("1:"+src.getBytes("GB2312"))%> </td>
<td> <%=("2:"+new String(src.getBytes()))%> </td>
<td> <%=("6:"+new String(src.getBytes(),"GB2312"))%> </td>
<td> <%=("7:"+new String(src.getBytes(),"ISO-8859-1"))%> </td>
<td> <%=("8:"+new String(src.getBytes("GB2312")))%> </td>
<td> <%=("9:"+new String(src.getBytes("GB2312"),"GB2312"))%> </td>
<td> <%=("10:"+new String(src.getBytes("GB2312"),"ISO-8859-1"))%> </td>
<td> <%=("11:"+new String(src.getBytes("ISO-8859-1")))%> </td>
<td> <%=("12:"+new String(src.getBytes("ISO-8859-1"),"GB2312"))%> </td>
<td> <%=("13:"+new String(src.getBytes("iso-8859-1"),"gb2312"))%> </td>
<td> <%=("14:"+new String(src.getBytes("utf-8"),"gb2312"))%> </td>
<td> <%=("15:"+new String(src.getBytes("UTF-8"),"gb2312"))%> </td>
<td> <%=("16:"+new String(src.getBytes("utf-8"),"ISO-8859-1"))%> </td>
<td> <%=("17:"+new String(src.getBytes("UTF-16"),"gb2312"))%> </td>
<td> <%=("18:"+new String(src.getBytes("UTF-8")))%> </td>
<td> <%=("19:"+new String(src.getBytes("ISO-8859-1")))%> </td>
<td> <%=("20:"+new String(src.getBytes("ISO-8859-1"),"UTF-8"))%> </td>
<td> <%=("21:"+new String(src.getBytes("GB2312"),"UTF-8"))%> </td>
<td> <%=("22:"+new String(src.getBytes("US-ASCII"),"GB2312"))%> </td>
</tr>
<tr><td>asdfasdfasdfasdf</tr>
<% int i = 0;
while (rs1.next()) {
for (int column = 1; column < 3; column++) {
i++;
%>
<% System.out.println(new String(rs1.getString(column).getBytes()));
System.out.println(new String(rs1.getString(column).getBytes(),"GB2312"));
System.out.println(new String(rs1.getString(column).getBytes("ISO-8859-1"),"GBK"));
System.out.println(new String(rs1.getString(column).getBytes("GBK"),"ISO-8859-1"));

%>
<tr>


</tr>
<tr> <td> <%=("a1:"+rs1.getString(column))%> </td>
<td> <%=("1:"+rs1.getString(column).getBytes("GB2312"))%> </td>
<td> <%=("2:"+new String(rs1.getString(column).getBytes()))%> </td>
<td> <%=("6:"+new String(rs1.getString(column).getBytes(),"GB2312"))%> </td>
<td> <%=("7:"+new String(rs1.getString(column).getBytes(),"ISO-8859-1"))%> </td>
<td> <%=("8:"+new String(rs1.getString(column).getBytes("GB2312")))%> </td>
<td> <%=("9:"+new String(rs1.getString(column).getBytes("GB2312"),"GB2312"))%> </td>
<td> <%=("10:"+new String(rs1.getString(column).getBytes("GB2312"),"ISO-8859-1"))%> </td>
<td> <%=("11:"+new String(rs1.getString(column).getBytes("ISO-8859-1")))%> </td>
<td> <%=("12:"+new String(rs1.getString(column).getBytes("ISO-8859-1"),"GB2312"))%> </td>
<td> <%=("13:"+new String(rs1.getString(column).getBytes("iso-8859-1"),"gb2312"))%> </td>
<td> <%=("14:"+new String(rs1.getString(column).getBytes("utf-8"),"gb2312"))%> </td>
<td> <%=("15:"+new String(rs1.getString(column).getBytes("UTF-8"),"gb2312"))%> </td>
<td> <%=("16:"+new String(rs1.getString(column).getBytes("utf-8"),"ISO-8859-1"))%> </td>
<td> <%=("17:"+new String(rs1.getString(column).getBytes("UTF-16"),"gb2312"))%> </td>
<td> <%=("18:"+new String(rs1.getString(column).getBytes("UTF-8")))%> </td>
<td> <%=("19:"+new String(rs1.getString(column).getBytes("ISO-8859-1")))%> </td>
<td> <%=("20:"+new String(rs1.getString(column).getBytes("ISO-8859-1"),"UTF-8"))%> </td>
<td> <%=("21:"+new String(rs1.getString(column).getBytes("GB2312"),"UTF-8"))%> </td>
<td> <%=("22:"+new String(rs1.getString(column).getBytes("US-ASCII"),"GB2312"))%> </td>
</tr>
<% }
}
%>
</table>
</form>
</body>
</html>
乱码如下:
oracle.jdbc.driver.ScrollableResultSet@73cc11

1:[B@5a9c6e 2:12345上解销号ABCDE 6:12345上解销号ABCDE 7:12345?????ú??ABCDE 8:12345上解销号ABCDE 9:12345上解销号ABCDE 10:12345?????ú??ABCDE 11:12345????ABCDE 12:12345????ABCDE 13:12345????ABCDE 14:12345涓?瑙i?????ABCDE 15:12345涓?瑙i?????ABCDE 16:12345???è§?é????·ABCDE 17:??12345N ???S?ABCDE 18:12345涓婅В閿?鍙稟BCDE 19:12345????ABCDE 20:12345????ABCDE 21:12345??????ABCDE 22:12345????ABCDE
asdfasdfasdfasdf
a1:88 1:[B@d420eb 2:88 6:88 7:88 8:88 9:88 10:88 11:88 12:88 13:88 14:88 15:88 16:88 17:??88 18:88 19:88 20:88 21:88 22:88
a1:12345????????ABCDE 1:[B@bd4dc2 2:12345????????ABCDE 6:12345?1?7?1?7?1?7?1?7?1?7?1?7?1?7?1?7ABCDE 7:12345?1¤7?1¤7?1¤7?1¤7?1¤7?1¤7?1¤7?1¤7ABCDE 8:12345????????ABCDE 9:12345????????ABCDE 10:12345????????ABCDE 11:12345????????ABCDE 12:12345????????ABCDE 13:12345????????ABCDE 14:12345锟斤拷锟斤拷锟斤拷锟斤拷ABCDE 15:12345锟斤拷锟斤拷锟斤拷锟斤拷ABCDE 16:12345????????????????????????ABCDE 17:??12345????????????????ABCDE 18:12345锟斤拷锟斤拷锟斤拷锟斤拷ABCDE 19:12345????????ABCDE 20:12345????????ABCDE 21:12345????????ABCDE 22:12345????????ABCDE
a1:11 1:[B@3c0737 2:11 6:11 7:11 8:11 9:11 10:11 11:11 12:11 13:11 14:11 15:11 16:11 17:??11 18:11 19:11 20:11 21:11 22:11
a1:???????????? 1:[B@fde050 2:???????????? 6:?1?7?1?7?1?7?1?7?1?7?1?7?1?7?1?7?1?7?1?7?1?7?1?7 7:?1¤7?1¤7?1¤7?1¤7?1¤7?1¤7?1¤7?1¤7?1¤7?1¤7?1¤7?1¤7 8:???????????? 9:???????????? 10:???????????? 11:???????????? 12:???????????? 13:???????????? 14:锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷 15:锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷 16:???????????????????????????????????? 17:?????????????????????????? 18:锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷 19:???????????? 20:???????????? 21:???????????? 22:????????????
a1:20 1:[B@191dd1d 2:20 6:20 7:20 8:20 9:20 10:20 11:20 12:20 13:20 14:20 15:20 16:20 17:??20 18:20 19:20 20:20 21:20 22:20
a1:???????? 1:[B@14bcae9 2:???????? 6:?1?7?1?7?1?7?1?7?1?7?1?7?1?7?1?7 7:?1¤7?1¤7?1¤7?1¤7?1¤7?1¤7?1¤7?1¤7 8:???????? 9:???????? 10:???????? 11:???????? 12:???????? 13:???????? 14:锟斤拷锟斤拷锟斤拷锟斤拷 15:锟斤拷锟斤拷锟斤拷锟斤拷 16:???????????????????????? 17:?????????????????? 18:锟斤拷锟斤拷锟斤拷锟斤拷 19:???????? 20:???????? 21:???????? 22:????????
a1:21 1:[B@f690e4 2:21 6:21 7:21 8:21 9:21 10:21 11:21 12:21 13:21 14:21 15:21 16:21 17:??21 18:21 19:21 20:21 21:21 22:21
a1:???????????? 1:[B@1a29450 2:???????????? 6:?1?7?1?7?1?7?1?7?1?7?1?7?1?7?1?7?1?7?1?7?1?7?1?7 7:?1¤7?1¤7?1¤7?1¤7?1¤7?1¤7?1¤7?1¤7?1¤7?1¤7?1¤7?1¤7 8:???????????? 9:???????????? 10:???????????? 11:???????????? 12:???????????? 13:???????????? 14:锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷 15:锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷 16:???????????????????????????????????? 17:?????????????????????????? 18:锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷 19:???????????? 20:???????????? 21:???????????? 22:????????????

搜索更多相关主题的帖子: quot 乱码 import page java 
2006-02-07 10:35
laoxie3
Rank: 1
等 级:新手上路
帖 子:6
专家分:0
注 册:2006-1-25
收藏
得分:0 

终于找到解决办法了:
原来Statement stmt = conn.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,ResultSet.CONCUR_UPDATABLE);
应该修改为:
Statement stmt = conn.createStatement();
就可以了,
哎真是太麻烦了。

2006-02-07 14:31
快速回复:乱码问题(找了很多资料也没有办法)
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.017872 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved