我有两个java源程序,如下:
程序1
package com.book;
import com.book.DataSourceConnection;
import java.sql.*;
import java.util.*;
import java.util.Vector;
class BookBean
{
private Connection con = null;
Vector v = null;
PageBean pageBean = null;
public BookBean()
{
try
{
con = DataSourceConnection.getConnection();
}
catch(Exception e)
{
System.out.println(e);
}
v = new Vector();
}
public int getAvailableCount() throws Exception
{
int count = 0;
String sql = “select count(*) as c from book“;
Statement stmt = con.createStatement();
ResultSet rs = stmt.executeQuery(sql);
while(rs.next())
{
count = rs.getInt(“c“);
}
return count;
}
public PageBean listData(String page) throws Exception
{
pageBean = new PageBean(this);
int pageNum = Integer.parseInt(page);
Statement stmt = con.createStatement();
String sql = “select top“+pageNum*pageBean.rowsPerPage+“* from book order by BookName“;
ResultSet rs = stmt.executeQuery(sql);
int i = 0;
while(rs.next())
{
if(i>(pageNum-1)*pageBean.rowsPerPage-1)
{
Object[] obj = new Object[4];
obj[0] = rs.getString(“BookID“);
obj[1] = rs.getString(“BookName“);
obj[2] = rs.getString(“Publisher“);
obj[3] = rs.getString(“Price“);
v.add(obj);
}
i++;
}
rs.close();
stmt.close();
pageBean.curPage = pageNum;
pageBean.data = v;
return pageBean;
}
public Vector getResult() throws Exception
{
return v;
}
}
程序2
package com.book;
public class PageBean
{
public int curPage;//当前是第几页
public int maxPages;//共页数
public int maxRows;//总行数
public int rowsPerPage=5;//每页的行数
public Vector data;//当前页要显示的资料
public PageBean(BookBean book) throws Exception
{
this.maxRows = book.getAvailableCount();
this.data = book.getResult();
this.countMaxPage();
}
public void countMaxPage()
{
if(this.maxRows%rowsPerPage==0)
{
this.maxPages = this.maxRows/this.rowsPerPage;
}
else
{
this.maxPages = this.maxRows/this.rowsPerPage + 1;
}
}
public Vector getResult()
{
return this.data;
}
}
现在要编译这两个源程序,但是程序1用到了程序2编译后的类,而程序2用到了程序1编译后的类,最后导致两个类都不能编译,现在不想把这两个类合成一个,因为在JSP中要通过jsp:useBean使用他们,请问哪位高手可以帮帮忙啊,万分感谢!!!!!!
人打赏
0人 点赞
主帖获得的天涯分:0
举报 |
楼主
|
楼主发言:1次 发图:0张 | 添加到话题 |