Java开发网 Java开发网
注册 | 登录 | 帮助 | 搜索 | 排行榜 | 发帖统计  

您没有登录

» Java开发网 » Servlet/JSP/JSF/JavaFX Script  

按打印兼容模式打印这个话题 打印话题    把这个话题寄给朋友 寄给朋友    该主题的所有更新都将Email到你的邮箱 订阅主题
reply to postflat modethreaded modego to previous topicgo to next topicgo to back
作者 读取Javabean的问题
ququ_0811





发贴: 17
于 2006-04-07 09:36 user profilesend a private message to usersend email to ququ_0811reply to postsearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
<%@ page contentType="text/html;charset=gb2312"%>
<%@ page import="java.sql.*"%>
<%@ page import="java.io.*"%>
<%@ page import="java.util.*"%>
<jsp:useBean   id="hb"  class="entitybean.HB" scope="request"/>
<jsp:setProperty name="hb"  property="*"/>
<html>
<body>
<%!String sql="select * from xt_gzhb_hbzz where 1=1 ";%>
<%
String nr=request.getParameter("nr");
String jlr=request.getParameter("jlr");
String jlsj=request.getParameter("jlsj").substring(0,7);
//String nr=hb.getNr();
//String jlr=hb.getJlr();
//String jlsj=hb.getJlsj();
String sql="select * from xt_gzhb_hbzz where 1=1 ";
System.out.println("111111111 = "+nr);
System.out.println("111111111 = "+jlr);
System.out.println("111111111 = "+jlsj);

String url="jdbc:oracle:thinAngry192.168.0.80:1521:ORA92";
String user="111";
String password="111";

ResultSet rs = null;
Connection conn = null;
java.sql.Statement stmt = null;

Class.forName("oracle.jdbc.driver.OracleDriver").newInstance();
conn= DriverManager.getConnection(url,user,password);
stmt=conn.createStatement();
try {
if(!(nr.equals("") || nr == null))
{
System.out.println("444444:::::"+nr);
  sql +=" and hbnr like '%"+nr+"%'";  
}
if(!(jlr.equals("") || jlr==null))
{
  System.out.println("444444:::::"+jlr);
  sql +=" and hbr='"+jlr+"'";
}
if(!(jlsj.equals("") || jlsj == null))
{  
  System.out.println("444444:::::"+jlsj);
  sql +=" and substr(to_char(hbsj,'yyyy-MM-dd'),0,7)='"+jlsj+"'";
  }
//  String sql="select * from xt_gzhb_hbzz where 1=1 " ;
//substr(to_char(hbsj,'yyyy-MM-dd'),0,7)=substr('"+jlsj+"',0,7)
rs =stmt.executeQuery(sql);
//out.println("sql"+sql);
//if(!rs.next()){
while(rs.next()) {%>
汇报内容:<%=rs.getString(2)%> </br>
记录人:<%=rs.getString(3)%> </br>
记录时间:<%=rs.getString(4)%></br>
<%}
rs.close();
stmt.close();
} catch (Exception e) {
System.err.println("erro"+e);
} finally {
try {
if (conn!=null)
conn.close();
} catch (Exception e) {
   System.err.println("erro"+e);   
}
} %>


</body>
</html>
我想问一下为什么request.getParameter("nr");取得参数可以运行得到结果,而用javabean的方法取得就抛出NULL异常呢?




JAVA学习日子分享

话题树型展开
人气 标题 作者 字数 发贴时间
1257 读取Javabean的问题 ququ_0811 2313 2006-04-07 09:36

reply to postflat modethreaded modego to previous topicgo to next topicgo to back
  已读帖子
  新的帖子
  被删除的帖子
Jump to the top of page

   Powered by Jute Powerful Forum® Version Jute 1.5.6 Ent
Copyright © 2002-2021 Cjsdn Team. All Righits Reserved. 闽ICP备05005120号-1
客服电话 18559299278    客服信箱 714923@qq.com    客服QQ 714923