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

<%@ 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
yangwudong
Rank: 3Rank: 3
等 级:新手上路
威 望:7
帖 子:244
专家分:0
注 册:2005-8-18
收藏
得分:0 
你还挺强来,自己的问题自己解决了,呵呵,我才看到!不好意思啊!

别做程序了,给你们一个赚钱的秘诀。做豆腐;if 做硬了 then 卖豆腐干;if 做稀了 then 卖豆腐花;if 太稀了 then 卖豆浆;if 豆腐卖不动了放几天 then 卖臭豆腐; else if 还卖不动放坏了 then 卖腐乳;
2006-02-07 15:53
神vLinux飘飘
Rank: 13Rank: 13Rank: 13Rank: 13
来 自:浙江杭州
等 级:贵宾
威 望:91
帖 子:6140
专家分:217
注 册:2004-7-17
收藏
得分:0 
jsp页面竟然可以这样写...

淘宝杜琨
2006-02-08 10:54
可可℃乐
Rank: 2
等 级:新手上路
威 望:3
帖 子:1054
专家分:0
注 册:2006-5-9
收藏
得分:0 
我用的是MYSQL,也是 Statement stmt = conn.createStatement();
就能连上拉,我都不知道为什么还要传递参数......?/

[url=http://www.]网页设计教程[/url]
2006-05-15 16:52
俊杰4585
Rank: 2
等 级:论坛游民
威 望:2
帖 子:45
专家分:27
注 册:2011-12-31
收藏
得分:0 
编码格式改成 utf-8试试
2012-05-07 22:37
快速回复:乱码问题(找了很多资料也没有办法)
数据加载中...
 
   



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

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