<%@ page language="java" import="java.io.*,java.sql.*,javax.sql.* ,javax.naming.*"%>
<%@ page contentType="text/html;charset=GB2312" errorPage="error.jsp"%>
<%request.setCharacterEncoding("gb2312");
//String sDBDriver = "oracle.jdbc.driver.OracleDriver";
//String sConnStr = "jdbc:oracle:thin:@10.216.10.106:1521:dbsvr";
String sDBDriver = "oracle.jdbc.driver.OracleDriver";
String sConnStr = "jdbc:oracle:thin:@10.216.10.106:1521:dbsvr";
Connection conn = null;
ResultSet rs = null;
Statement stmt = null;
try
{
Class.forName(sDBDriver);
conn = DriverManager.getConnection(sConnStr,"hello","oracle");
stmt = conn.createStatement();
rs = stmt.executeQuery("select * from 权限_用户帐号");
%>
<%
while (rs.next()){
out.println("" + rs.getInt(1) + "");
out.println(":"+"<br>");
//out.println(" + rs.getString('answers') + ");
}
rs.close();
}
catch(Exception e)
{
out.println(e);
}
%>
5 个解决方案
#1
页面结果:java.sql.SQLException: Fail to convert to internal representation
#2
明白了,是中文问题,数据库表名是中文名,编码可能不对,换一个英文名表就好了。
那这个中文表名问题怎么解决呢?
那这个中文表名问题怎么解决呢?
#3
学习...
#4
自己解决。读数据转换一下就好了。
while (rs.next()){
strB = new String(rs.getString(1).getBytes("ISO8859_1"),"gb2312");
//out.println("" + rs.getInt(1) + "");
out.println("" + strB + "");
out.println(":"+"<br>");
}
为什么提交sql不需要转换一下呢?
while (rs.next()){
strB = new String(rs.getString(1).getBytes("ISO8859_1"),"gb2312");
//out.println("" + rs.getInt(1) + "");
out.println("" + strB + "");
out.println(":"+"<br>");
}
为什么提交sql不需要转换一下呢?
#5
老规矩,明天结帖,跟帖有分!
#1
页面结果:java.sql.SQLException: Fail to convert to internal representation
#2
明白了,是中文问题,数据库表名是中文名,编码可能不对,换一个英文名表就好了。
那这个中文表名问题怎么解决呢?
那这个中文表名问题怎么解决呢?
#3
学习...
#4
自己解决。读数据转换一下就好了。
while (rs.next()){
strB = new String(rs.getString(1).getBytes("ISO8859_1"),"gb2312");
//out.println("" + rs.getInt(1) + "");
out.println("" + strB + "");
out.println(":"+"<br>");
}
为什么提交sql不需要转换一下呢?
while (rs.next()){
strB = new String(rs.getString(1).getBytes("ISO8859_1"),"gb2312");
//out.println("" + rs.getInt(1) + "");
out.println("" + strB + "");
out.println(":"+"<br>");
}
为什么提交sql不需要转换一下呢?
#5
老规矩,明天结帖,跟帖有分!