资源简介
孙卫琴《Tomcat与Java Web开发技术详解》第二版光盘完整源代码,共33章,本人也在学习,代码可以直接运行,共33章的代码,完整版
代码片段和文件信息
/** 直接通过JDBC API 访问MySQL数据库 */
package mypack;
import java.sql.*;
import javax.naming.*;
import javax.sql.*;
import java.util.*;
public class BookDB {
private String dbUrl = “jdbc:mysql://localhost:3306/BookDB“;
private String dbUser=“dbuser“;
private String dbPwd=“1234“;
public BookDB () throws Exception{
Class.forName(“com.mysql.jdbc.Driver“);
}
public Connection getConnection()throws Exception{
return java.sql.DriverManager.getConnection(dbUrldbUserdbPwd);
}
public void closeConnection(Connection con){
try{
if(con!=null) con.close();
}catch(Exception e){
e.printStackTrace();
}
}
public void closePrepStmt(PreparedStatement prepStmt){
try{
if(prepStmt!=null) prepStmt.close();
}catch(Exception e){
e.printStackTrace();
}
}
public void closeResultSet(ResultSet rs){
try{
if(rs!=null) rs.close();
}catch(Exception e){
e.printStackTrace();
}
}
public int getNumberOfBooks() throws Exception {
Connection con=null;
PreparedStatement prepStmt=null;
ResultSet rs=null;
int count=0;
try {
con=getConnection();
String selectStatement = “select count(*) “ + “from BOOKS“;
prepStmt = con.prepareStatement(selectStatement);
rs = prepStmt.executeQuery();
if (rs.next())
count = rs.getInt(1);
}finally{
closeResultSet(rs);
closePrepStmt(prepStmt);
closeConnection(con);
}
return count;
}
public Collection getBooks()throws Exception{
Connection con=null;
PreparedStatement prepStmt=null;
ResultSet rs =null;
ArrayList books = new ArrayList();
try {
con=getConnection();
String selectStatement = “select * “ + “from BOOKS“;
prepStmt = con.prepareStatement(selectStatement);
rs = prepStmt.executeQuery();
while (rs.next()) {
BookDetails bd = new BookDetails(rs.getString(1) rs.getString(2) rs.getString(3)
rs.getFloat(4) rs.getInt(5) rs.getString(6)rs.getInt(7));
books.add(bd);
}
}finally{
closeResultSet(rs);
closePrepStmt(prepStmt);
closeConnection(con);
}
Collections.sort(books);
return books;
}
public BookDetails getBookDetails(String bookId) throws Exception {
Connection con=null;
PreparedStatement prepStmt=null;
ResultSet rs =null;
try {
con=getConnection();
String selectStatement = “select * “ + “from BOOKS where ID = ? “;
prepStmt = con.prepareStatement(selectStatement);
prepStmt.setString(1 bookId);
rs = prepStmt.executeQuery();
if (rs.next()) {
BookDetails bd = new BookDetails(rs.getString(1) rs.getString(2) rs.getString(3)
rs.getFloat(4) rs.getInt(5) rs.getString(6)rs.getInt(7));
prepStmt.close();
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
目录 0 2019-01-24 09:56 sourcecode\
目录 0 2018-01-28 11:25 sourcecode\bookstores\
文件 909 2008-07-12 12:42 sourcecode\bookstores\books.sql
目录 0 2018-01-28 11:25 sourcecode\bookstores\version0\
目录 0 2018-01-28 11:25 sourcecode\bookstores\version0\bookstore\
文件 41 2008-07-12 12:42 sourcecode\bookstores\version0\bookstore\banner.jsp
文件 1099 2008-07-12 12:42 sourcecode\bookstores\version0\bookstore\bookdetails.jsp
文件 509 2008-07-12 12:42 sourcecode\bookstores\version0\bookstore\bookstore.jsp
文件 1392 2008-07-12 12:42 sourcecode\bookstores\version0\bookstore\build.xm
文件 1255 2008-07-12 12:42 sourcecode\bookstores\version0\bookstore\build0.xm
文件 832 2008-07-12 12:42 sourcecode\bookstores\version0\bookstore\cashier.jsp
文件 1540 2008-07-12 12:42 sourcecode\bookstores\version0\bookstore\catalog.jsp
文件 349 2008-07-12 12:42 sourcecode\bookstores\version0\bookstore\common.jsp
文件 353 2008-07-12 12:42 sourcecode\bookstores\version0\bookstore\errorpage.jsp
文件 29382 2008-07-12 12:42 sourcecode\bookstores\version0\bookstore\logo.bmp
文件 600 2008-07-12 12:42 sourcecode\bookstores\version0\bookstore\receipt.jsp
文件 2402 2008-07-12 12:42 sourcecode\bookstores\version0\bookstore\showcart.jsp
目录 0 2018-01-28 11:25 sourcecode\bookstores\version0\bookstore\src\
目录 0 2018-01-28 11:25 sourcecode\bookstores\version0\bookstore\src\mypack\
文件 5015 2008-07-12 12:42 sourcecode\bookstores\version0\bookstore\src\mypack\BookDB.java
文件 1612 2008-07-12 12:42 sourcecode\bookstores\version0\bookstore\src\mypack\BookDetails.java
文件 1981 2008-07-12 12:42 sourcecode\bookstores\version0\bookstore\src\mypack\ShoppingCart.java
文件 762 2008-07-12 12:42 sourcecode\bookstores\version0\bookstore\src\mypack\ShoppingCartItem.java
目录 0 2018-01-28 11:25 sourcecode\bookstores\version0\bookstore\WEB-INF\
目录 0 2018-01-28 11:25 sourcecode\bookstores\version0\bookstore\WEB-INF\classes\
目录 0 2018-01-28 11:25 sourcecode\bookstores\version0\bookstore\WEB-INF\classes\mypack\
文件 5186 2008-07-12 12:42 sourcecode\bookstores\version0\bookstore\WEB-INF\classes\mypack\BookDB.class
文件 1590 2008-07-12 12:42 sourcecode\bookstores\version0\bookstore\WEB-INF\classes\mypack\BookDetails.class
文件 2420 2008-07-12 12:42 sourcecode\bookstores\version0\bookstore\WEB-INF\classes\mypack\ShoppingCart.class
文件 788 2008-07-12 12:42 sourcecode\bookstores\version0\bookstore\WEB-INF\classes\mypack\ShoppingCartItem.class
目录 0 2018-01-28 11:25 sourcecode\bookstores\version0\bookstore\WEB-INF\lib\
............此处省略1474个文件信息
相关资源
- websockets实现tomcat日志在线输出
- Spring4.2.9+mybatis3.4.4集成整合Jackson版支
- apache-tomcat-7.0.86.tar.gz
- 完整的宿舍管理系统
- android 如何使用tomcat搭建服务器
- Java Web开发实战经典
- tomcat 采用msm连接memcached缓存session所需
- jira6.3汉化包
- Eclipse+Tomcat开发web应用
- tomcat+nginx反向代理集群配置.zip
- xp安装 JDK+TOMCAT+MYSQL+jsp论坛
- tomcat 8.5.31
- apache-tomcat-7.0.63-windows-x64.zip
- redis-tomcat8以上集群所需要的jar :tomc
- 宾馆管理系统jsp完整源代码
- JSP+Servlet+Tomcat个人博客系统
- jsf2.0 完整(含所有jar包)
- jsp大作业-在线学习平台MyEclipse+Mysql
- JSP+Mysql教师教学质量测评系统论文
- apache-tomcat-6.0.32
- tomcat6.0.26绿色版
- Struts2框架完成一个简单的留言板包含
- OpenBlog---tomcat 的个人博客网站
- tomcat基于Web的JSP+Servlet学生信息管理系
- 企业人事工资管理系统219562
- tomcat常用jar包
- tomcat-redis-session-manager 所需jar包 共
- apache-tomcat-8.5.20.tar.gz
- apache-tomcat-8.5.16
- 网上花店销售系统jsp
评论
共有 条评论