数据库里是汉字,从数据库获取后就变成乱码了
stmt = conn.createStatement();rs = stmt.executeQuery(new String(_getQueryStateDetail(hashParms, out).getBytes("GB2312"),"Cp949") );//这里有转换啊
int totLine = printDataSet(vec, rs, hashParms, out);
public int printDataSet( java.util.Vector vec, java.sql.ResultSet rs, java.util.Hashtable hashParms, PrintWriter out ) {
int iSkipCnt = (Integer.parseInt(hashParms.get("move_page").toString()) - 1 ) * ROW_NUM;
int pageCnt = 0;
int colCnt = 0;
// int k = 0;
try{
int totLine = 0;
ResultSetMetaData rsmt = rs.getMetaData();
colCnt = rsmt.getColumnCount();
// String StrBuf = "";
while ( rs.next() ) {
totLine++;
String str[] = null;
if( getInsFlag(totLine, pageCnt, iSkipCnt, hashParms, out) ){
str = new String[colCnt + 1];
str[0] = String.valueOf(totLine);
for( int i = 1; i <= colCnt; i++ ){
str[i] = super._getStringObject(rs.getObject(i));
}
vec.addElement(str);
pageCnt++;
}
}
return totLine;
}
catch( Exception e ) {
out.println("setting Data: " + e.getMessage());
e.printStackTrace();
return 0;
}
}
while ( row < vec.size() ) {
str = (String[])vec.elementAt(row++);
out.println("<tr id=trR class="+bgcolor+" onmouseover='rollOverR(this,"+(row-1)+")' onmouseout='rollOutR(this,"+(row-1)+")'>");
//
out.println(" <td nowrap "+tdWidth+" class=taxt_center height=19> "+str[5]+"</td>");
out.println(" <td nowrap "+tdWidth+" class=taxt_center height=19> "+str[6]+"</td>");
System.out.println("111111"+str[6]);//这样输出来之后就是乱码了
怎么样从数据库里获取然后输出来不是乱码啊? --------------------编程问答-------------------- 你数据库字符类型是 --------------------编程问答--------------------
VARCHAR2(50) --------------------编程问答-------------------- AMERICAN_AMERICA.KO16KSC5601编码是这个 --------------------编程问答-------------------- 这是 mssql啊 没用过
补充:Java , Java相关