<%@ page contentType= "text/html; charset=gb2312 " language= "java " import= "java.sql.* " errorPage= " " %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN " "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd ">
<html xmlns= "http://www.w3.org/1999/xhtml ">
<head>
<meta http-equiv= "Content-Type " content= "text/html; charset=gb2312 " />
<title> 无标题文档 </title>
</head>
<body>
<%!
java.sql.Connection Conn = null;
java.sql.ResultSet rs = null;
%>
<%
try {
Class.forName( "oracle.jdbc.driver.OracleDriver ").newInstance();
Conn= DriverManager.getConnection( "jdbc:oracle:thin:@192.168.1.147:1521:OEMREP ", "system ", "manager ");
Statement stmt = Conn.createStatement();
rs = stmt.executeQuery( "select CORP_NAME,CORP_CODE from T_B_CORP where SUP_CORP_CODE= '420100000001 ' and IS_USE= '1 ' ");
out.println( "123 ");
}
catch (Exception e)
{
System.out.print(e);
}
%>
</body>
</html>
为什么我把out.println( "123 ");放在rs = stmt.executeQuery( "select CORP_NAME,CORP_CODE from T_B_CORP where SUP_CORP_CODE= '420100000001 ' and IS_USE= '1 ' ");后面不能显示123,而我放在其他位置都可以显示,可以连接数据库,而且数据库里有数据,但是就显示不出数据来!!
<%
while(rs.next())
{
out.println(rs.getString( "CORP_NAME "));
}
rs.close();
%>
上面这个程序不起作用,显示不出数据来!!
这个问题很奇怪,希望大家帮我看看!!
------解决方案--------------------
我在自己机器上测试能出来啊,lz的代码没有问题。
SQL> create table T_B_CORP
2 (
3 CORP_NAME varchar2(10),
4 CORP_CODE varchar2(10),
5 SUP_CORP_CODE varchar(20),
6 IS_USE char(1)
7 );
表已创建。
SQL> insert into T_B_CORP values( 'aaa ', '123 ', '420100000001 ', '1 ');
已创建 1 行。
SQL> insert into T_B_CORP values( 'bbb ', '456 ', '420100000002 ', '0 ');
已创建 1 行。
SQL> commit;
提交完成。
SQL> select * from T_B_CORP;
CORP_NAME CORP_CODE SUP_CORP_CODE I
---------- ---------- -------------------- -
aaa 123 420100000001 1
bbb 456 420100000002 0
<%@ page contentType= "text/html; charset=gb2312 " language= "java "
import= "java.sql.* " errorPage= " "%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN " "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd ">
<html xmlns= "http://www.w3.org/1999/xhtml ">
<head>