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

您没有登录

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

按打印兼容模式打印这个话题 打印话题    把这个话题寄给朋友 寄给朋友    该主题的所有更新都将Email到你的邮箱 订阅主题
reply to postflat modethreaded modego to previous topicgo to next topicgo to back
作者 Re:为什么这样不能分页呢? [Re:sisili]
sisili





发贴: 6
于 2004-09-16 10:30 user profilesend a private message to userreply to postsearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
我把数据库连接bean和运行结果的图也贴出来,请大家给我看看吧

WebDataModule.java如下所示:

import com.borland.dx.dataset.*;
import com.borland.dx.sql.dataset.*;
import java.sql.*;

public class WebDataModule {
public Connection conn;
Statement totalStmt;
Statement StudentInfoPageStmt;
Statement HallMenuPageStmt;
ResultSet HallMenuRs;
ResultSet StudentInfoRs;
public WebDataModule(){
try {jbInit();}
catch(Exception e) {e.printStackTrace();}
}
private void jbInit() throws Exception {
String url = "jdbc:odbc:OrderFoodSQLServer";
//创建连接类
Connection conn;
//告诉程序使用jdbc与odbc桥创建数据库联接
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
//使用DriverManager类的getConnection()方法建立联接,
//第一个字符参数定义用户名,第二个字符参数定义密码
conn = DriverManager.getConnection(url, "sa", "sa");

//创建获取全部数据的Statement类
totalStmt = conn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,
ResultSet.CONCUR_READ_ONLY);
//创建获取分页数据的Statement类,取得StudentInfor数据表的数据
StudentInfoPageStmt = conn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,
ResultSet.CONCUR_READ_ONLY);
//创建获取分页数据的Statement类,取得HallMenu数据表的数据
HallMenuPageStmt = conn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,
ResultSet.CONCUR_READ_ONLY);
//设置每页的记录数
StudentInfoPageStmt.setMaxRowsDevil;
HallMenuPageStmt.setMaxRowsDevil;
}
//取得食堂菜单数据表的数据
public ResultSet getHallMenuRs() {
try{
HallMenuRs = totalStmt.executeQuery("select * from HallMenu");
}catch(Exception ex){ex.printStackTrace();}
return HallMenuRs;
}
//分页取得学生信息数据表的数据
public ResultSet getStudentInfoRs(int id) {
try{
StudentInfoRs = StudentInfoPageStmt.executeQuery("select * from StudentInfo where id >= "
+ id);
}catch(Exception ex){ex.printStackTrace();}
return StudentInfoRs;
}
//分页取得食堂菜单数据表的数据
public ResultSet getHallMenuRs(int id) {
try{
HallMenuRs = StudentInfoPageStmt.executeQuery("select * from HallMenu where id >= "
+ id);
}catch(Exception ex){ex.printStackTrace();}
return HallMenuRs;
}
//关闭数据库联接
public void closeConn(){
try{
conn.close();
}catch(Exception ex){ex.printStackTrace();}
}
}

(缩略图,点击图片链接看原图)




话题树型展开
人气 标题 作者 字数 发贴时间
1382 为什么这样不能分页呢? sisili 2688 2004-09-15 22:01
1044 Re:为什么这样不能分页呢? sunzy19810705 33 2004-09-16 08:37
1179 Re:为什么这样不能分页呢? sisili 2387 2004-09-16 10:30

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