WEB开发网
开发学院WEB开发Jsp 用CashFilter实现页面级缓存实践 阅读

用CashFilter实现页面级缓存实践

 2008-01-05 08:30:12 来源:WEB开发网   
核心提示:1.MySQL在本地localhost的test数据库 建person表,暂以字段id,name,passWord ,表中可输入一行值.2.建类 DAOUtil import java.sql.Connection;import java.sql.DriverManager;public class DAOUtil

1.MySQL在本地localhost的test数据库 建person表,暂以字段id,name,passWord ,表中可输入一行值.

2.建类 DAOUtil

import  java.sql.Connection;
import  java.sql.DriverManager;

public class DAOUtil {
   public DAOUtil() {
   }

  public static Connection getConn() {
     Connection conn = null;
     String db_url = "jdbc:mysql://127.0.0.1:3306/test?useUnicode=true&characterEncoding=gb2312";
     String db_user = "root";
     String db_password= "admin";
     String db_driver = "com.mysql.jdbc.Driver";

   try {
       Class.forName(db_driver);
       conn = DriverManager.getConnection(db_url, db_user, db_password);
       } catch (Exception ex) {
       ex.PRintStackTrace();
     }
     return conn;
   }

  /**
  * dbclose
  * 关闭Connection,Statement
  * @param conn Connection
  * @param stmt Statement
  */
 public static void dbclose(Connection conn, Statement stmt) {
    try {
      if (stmt != null)
        stmt.close();
    } catch (Exception e) {
     e.printStackTrace();
    }
    try {
      if (conn != null)
        conn.close();
    } catch (Exception e) {
      e.printStackTrace();
    }
  }

}

3.建类 PersonDAO

import java.util.*;
import java.sql.Connection;
import java.sql.Statement;
import java.sql.ResultSet;


public class PersonDAO {
   static PersonDAO pdao;
   public static PersonDAO getInstance() {
     if (pdao == null) {
       synchronized (PersonDAO.class) {
         pdao = new PersonDAO();
       }
     }
     return pdao;
   }


Tags:CashFilter 实现 页面

编辑录入:爽爽 [复制链接] [打 印]
赞助商链接