---
title: "我自己的数据对象处理类 CmsDAO"
author: "phantom"
date: "2007-03-03T06:21:14Z"
tags: []
slug: "cmsdao"
draft: false
lastmod: "2007-03-03T06:21:14Z"
id: 66094
url: "https://phantom.iteye.com/blog/66094"
---

package com.jh.core.db;

import java.sql.SQLException;  
import java.util.List;

import com.jh.app.util.Globle;  
import com.jh.core.db.jdbc.BaseDAO;  
import com.jh.core.util.JHPage;

public class CmsDAO&lt;T&gt; extends BaseDAO &lt;T&gt;{

 /\**  
  * 设定数据库  
  \*/  
 final public static String DB\_NAME = Globle.CMS\_DB;

 /\**  
  * @param clazz  
  \*/  
 @SuppressWarnings("unchecked")  
 public CmsDAO(Class&lt;T&gt; clazz) {  
  super(clazz);  
 }

 @Override  
 public String getDBName() {  
  return DB\_NAME;  
 }

 /\**  
  * 执行更新sql  
  *  
  * @param sql  
  * @return  
  * @throws SQLException  
  \*/  
 public static boolean execute(String sql) throws SQLException {  
  return BaseDAO.execute(DB\_NAME, sql);  
 }  
 public static void insertObj(String tableName, final String\[] columnName,  
   final List obj) {  
  BaseDAO.insertObjList(DB\_NAME, tableName, columnName, obj);  
 }  
 public static void updateObj(String tableName, final String\[] columnName,  
   final String\[] whereColumn, final List obj) {  
  BaseDAO.updateObj(DB\_NAME, tableName, columnName, whereColumn, obj);  
 }  
 public static void updateObj(String tableName, final String\[] columnName,  
   final String where, final List obj) {  
  BaseDAO.updateObj(DB\_NAME, tableName, columnName, where, obj);  
 }  
 /\**  
  * 通过sql获得对象  
  *  
  * @param sql  
  * @param clazz0  
  * @return  
  * @throws Exception  
  \*/  
 public static Object getObj(final String sql, final Class clazz0)  
   throws Exception {  
  return BaseDAO.getObj(DB\_NAME, sql, clazz0);  
 }

 /\**  
  * 获得对象list  
  *  
  * @param sql  
  * @param clazz0  
  * @return  
  * @throws Exception  
  \*/  
 public static List getObjList(final String sql, final Class clazz0)  
   throws Exception {  
  return BaseDAO.getObjList(DB\_NAME, sql, clazz0);  
 }

 /\**  
  * 获得分页对象list  
  *  
  * @param sql  
  * @param clazz0  
  * @param page  
  * @return  
  * @throws Exception  
  \*/  
 public static List getObjList(final String sql, final Class clazz0,  
   JHPage page) throws Exception {  
  return BaseDAO.getObjList(DB\_NAME, sql, clazz0, page);  
 }

 

 /\**  
  * 获得统计或者sql的取得的值  
  *  
  * @param sql  
  * @return  
  * @throws Exception  
  \*/  
 public static Object getValue(final String sql) throws Exception {  
  return BaseDAO.getValue(DB\_NAME, sql);

 }

 /\**  
  * 插入对象方法  
  *  
  * @param tableName  
  * @param columnName  
  * @param obj  
  \*/  
 public static Long insertObj(String tableName, final String\[] columnName,  
   final Object obj) {  
  return BaseDAO.insertObj(DB\_NAME, tableName, columnName, obj);  
 }

 /\**  
  * 更新对象方法  
  *  
  * @param tableName  
  * @param columnName  
  * @param whereColumn  
  * @param obj  
  \*/  
 public static void updateObj(String tableName, final String\[] columnName,  
   final String\[] whereColumn, final Object obj) {  
  BaseDAO.updateObj(DB\_NAME, tableName, columnName, whereColumn, obj);  
 }  
 /\**  
  *  更新对象方法  
  * Time: 2006-11-25 上午09:21:19  
  * User: phx  
  * @param tableName  
  * @param columnName  
  * @param where  
  * @param obj  
  \*/  
 public static void updateObj(String tableName, final String\[] columnName,  
   final String where, final Object obj) {  
  BaseDAO.updateObj(DB\_NAME, tableName, columnName, where, obj);  
 }

 /\**  
  * 批量执行sql update  
  *  
  * @param sqlList  
  * @return  
  * @throws SQLException  
  \*/  
 static public int\[] update(List sqlList) throws SQLException {  
  return BaseDAO.update(DB\_NAME, sqlList);

 }

 /\**  
  * 执行sql update  
  *  
  * @param sql  
  * @return  
  * @throws SQLException  
  \*/  
 static public int update(String sql) throws SQLException {  
  return BaseDAO.update(DB\_NAME, sql);  
 }

 /\**  
  * 获得指定条数的集合对象  
  *  
  * @param sql  
  * @param clazz0  
  * @param limit  
  * @return  
  * @throws Exception  
  \*/  
 public static List getObjList(String sql, Class clazz0, int limit)  
   throws Exception {  
  return BaseDAO.getObjList(DB\_NAME, sql, clazz0, limit);  
 }

 /\**  
  * 按指定sql获得对象  
  *  
  * @param sql  
  * @return  
  * @throws Exception  
  \*/  
}