用JAVABEAN返回的数据库记录在JSP中显示问题?
其中javabean如下:
dataconn.java
import java.sql.*;
public class DataConn{
public static Connection getDataConn() {
Connection conn = null;
try {
Class.forName( "oracle.jdbc.driver.OracleDriver ").newInstance();
conn = DriverManager.getConnection( "jdbc:oracle:thin:@localhost:1521:trans ", "trans ", "trans ");
}
catch(Exception ex) {
ex.printStackTrace();
}
return conn;
}
}
GetResult.java
:
import java.sql.*;
//import java.util.*;
//import java.io.*;
import javax.servlet.http.HttpSession;
import javax.servlet.http.HttpServletRequest;
public class GetResult{
private Connection conn;
private Date Date1;
private Date Date2;
public void setDate1(Date Date1){
this.Date1=Date1;
}
public void setDate2(Date Date1){
this.Date2=Date2;
}
public Date getDate1(){
return this.Date1;
}
public Date getDate2(){
return this.Date2;
}
public GetResult()throws Exception{
conn = DataConn.getDataConn();
}
public ResultSet getCounter()throws Exception{
//String session = this.getDepart();
//int ret = 0;
Statement stmt = conn.createStatement();
ResultSet rset = stmt.executeQuery( "select * from V_SITEDUTYRIZHITWO where DCURRDATE BETWEEN DATE1 AND DATE2 ");
//while(rset.next()){
//ret = rset.getInt(1);
return rset;
}
public void close(){
try{
if(!conn.isClosed()){
conn.close();
}
}catch(Exception ex){
ex.printStackTrace();
}
}
}
上面是否有错误,还有怎么才能把返回的符合条件的记录显示在JSP页面上 ,原页面有两个文本框和一个提交铵纽,文本框输入起始时间(标准),提交到显示所取到的记录..各位能帮帮我吗?
------解决方案-------------------- 方法都在里面定义好了
连库的方法 GetResult()
获得数据的 ResultSet getCounter() (是获得DATA1 到 DATA2之间的数据)
还有关闭连接的方法
想使用的话 在自己的类里边 调用这些方法就可以了,然后把得到的结果封装在VO中 然后在SERVLET中中带值传过去。然后在页面中调用就可以了~~~
------解决方案--------------------举个例子
<jsp:useBean id= "currency " class= "util.Currency " scope= "session "> <jsp:setProperty name= "currency " property= "locale " value= " <%= request.getLocale() %> "/> </jsp:useBean> <jsp:setProperty name= "currency "