《Tomcat与Java Web开发技术详解(第2版)》.(孙卫琴).源码
代码片段和文件信息
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 909 2008-07-12 12:42 sourcecodeookstoresooks.sql
文件 41 2008-07-12 12:42 sourcecodeookstoresversion0ookstoreanner.jsp
文件 1099 2008-07-12 12:42 sourcecodeookstoresversion0ookstoreookdetails.jsp
文件 509 2008-07-12 12:42 sourcecodeookstoresversion0ookstoreookstore.jsp
文件 1392 2008-07-12 12:42 sourcecodeookstoresversion0ookstoreuild.xml
文件 1255 2008-07-12 12:42 sourcecodeookstoresversion0ookstoreuild0.xml
文件 832 2008-07-12 12:42 sourcecodeookstoresversion0ookstorecashier.jsp
文件 1540 2008-07-12 12:42 sourcecodeookstoresversion0ookstorecatalog.jsp
文件 349 2008-07-12 12:42 sourcecodeookstoresversion0ookstorecommon.jsp
文件 353 2008-07-12 12:42 sourcecodeookstoresversion0ookstoreerrorpage.jsp
文件 29382 2008-07-12 12:42 sourcecodeookstoresversion0ookstorelogo.bmp
文件 600 2008-07-12 12:42 sourcecodeookstoresversion0ookstore
eceipt.jsp
文件 2402 2008-07-12 12:42 sourcecodeookstoresversion0ookstoreshowcart.jsp
文件 5015 2008-07-12 12:42 sourcecodeookstoresversion0ookstoresrcmypackBookDB.java
文件 1612 2008-07-12 12:42 sourcecodeookstoresversion0ookstoresrcmypackBookDetails.java
文件 1981 2008-07-12 12:42 sourcecodeookstoresversion0ookstoresrcmypackShoppingCart.java
文件 762 2008-07-12 12:42 sourcecodeookstoresversion0ookstoresrcmypackShoppingCartItem.java
文件 5186 2008-07-12 12:42 sourcecodeookstoresversion0ookstoreWEB-INFclassesmypackBookDB.class
文件 1590 2008-07-12 12:42 sourcecodeookstoresversion0ookstoreWEB-INFclassesmypackBookDetails.class
文件 2420 2008-07-12 12:42 sourcecodeookstoresversion0ookstoreWEB-INFclassesmypackShoppingCart.class
文件 788 2008-07-12 12:42 sourcecodeookstoresversion0ookstoreWEB-INFclassesmypackShoppingCartItem.class
文件 215441 2008-07-12 12:42 sourcecodeookstoresversion0ookstoreWEB-INFlibmysqldriver.jar
文件 212 2008-07-12 12:42 sourcecodeookstoresversion0ookstoreWEB-INFweb.xml
文件 42 2008-07-12 12:42 sourcecodeookstoresversion1ookstoreanner.jsp
文件 1099 2008-07-12 12:42 sourcecodeookstoresversion1ookstoreookdetails.jsp
文件 509 2008-07-12 12:42 sourcecodeookstoresversion1ookstoreookstore.jsp
文件 1255 2008-07-12 12:42 sourcecodeookstoresversion1ookstoreuild.xml
文件 832 2008-07-12 12:42 sourcecodeookstoresversion1ookstorecashier.jsp
文件 1540 2008-07-12 12:42 sourcecodeookstoresversion1ookstorecatalog.jsp
文件 348 2008-07-12 12:42 sourcecodeookstoresversion1ookstorecommon.jsp
............此处省略1479个文件信息
/** 直接通过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();
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 909 2008-07-12 12:42 sourcecodeookstoresooks.sql
文件 41 2008-07-12 12:42 sourcecodeookstoresversion0ookstoreanner.jsp
文件 1099 2008-07-12 12:42 sourcecodeookstoresversion0ookstoreookdetails.jsp
文件 509 2008-07-12 12:42 sourcecodeookstoresversion0ookstoreookstore.jsp
文件 1392 2008-07-12 12:42 sourcecodeookstoresversion0ookstoreuild.xm
文件 1255 2008-07-12 12:42 sourcecodeookstoresversion0ookstoreuild0.xm
文件 832 2008-07-12 12:42 sourcecodeookstoresversion0ookstorecashier.jsp
文件 1540 2008-07-12 12:42 sourcecodeookstoresversion0ookstorecatalog.jsp
文件 349 2008-07-12 12:42 sourcecodeookstoresversion0ookstorecommon.jsp
文件 353 2008-07-12 12:42 sourcecodeookstoresversion0ookstoreerrorpage.jsp
文件 29382 2008-07-12 12:42 sourcecodeookstoresversion0ookstorelogo.bmp
文件 600 2008-07-12 12:42 sourcecodeookstoresversion0ookstore
eceipt.jsp
文件 2402 2008-07-12 12:42 sourcecodeookstoresversion0ookstoreshowcart.jsp
文件 5015 2008-07-12 12:42 sourcecodeookstoresversion0ookstoresrcmypackBookDB.java
文件 1612 2008-07-12 12:42 sourcecodeookstoresversion0ookstoresrcmypackBookDetails.java
文件 1981 2008-07-12 12:42 sourcecodeookstoresversion0ookstoresrcmypackShoppingCart.java
文件 762 2008-07-12 12:42 sourcecodeookstoresversion0ookstoresrcmypackShoppingCartItem.java
文件 5186 2008-07-12 12:42 sourcecodeookstoresversion0ookstoreWEB-INFclassesmypackBookDB.class
文件 1590 2008-07-12 12:42 sourcecodeookstoresversion0ookstoreWEB-INFclassesmypackBookDetails.class
文件 2420 2008-07-12 12:42 sourcecodeookstoresversion0ookstoreWEB-INFclassesmypackShoppingCart.class
文件 788 2008-07-12 12:42 sourcecodeookstoresversion0ookstoreWEB-INFclassesmypackShoppingCartItem.class
文件 215441 2008-07-12 12:42 sourcecodeookstoresversion0ookstoreWEB-INFlibmysqldriver.jar
文件 212 2008-07-12 12:42 sourcecodeookstoresversion0ookstoreWEB-INFweb.xm
文件 42 2008-07-12 12:42 sourcecodeookstoresversion1ookstoreanner.jsp
文件 1099 2008-07-12 12:42 sourcecodeookstoresversion1ookstoreookdetails.jsp
文件 509 2008-07-12 12:42 sourcecodeookstoresversion1ookstoreookstore.jsp
文件 1255 2008-07-12 12:42 sourcecodeookstoresversion1ookstoreuild.xm
文件 832 2008-07-12 12:42 sourcecodeookstoresversion1ookstorecashier.jsp
文件 1540 2008-07-12 12:42 sourcecodeookstoresversion1ookstorecatalog.jsp
文件 348 2008-07-12 12:42 sourcecodeookstoresversion1ookstorecommon.jsp
............此处省略1479个文件信息
版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容, 请发送邮件举报,一经查实,本站将立刻删除。
评论列表(条)