?? commoncodedao.java
字號:
package com.publish.shop.util.dao;import java.sql.*;import java.util.ArrayList;import com.publish.shop.util.db.DbPool;import com.publish.shop.util.javabeans.*;import org.apache.struts.util.LabelValueBean;/** * 錕斤拷錕矯達拷錕斤拷錕紻AO錕斤拷錕斤拷薟錕斤拷錕斤拷錕\uFFFD * @author david * @version 1.0 */public class CommonCodeDAO{ public ArrayList getCommonCodeLabel(String codeType) { ArrayList list = new ArrayList(); String sql = "select CodeName,CodeValue from CommonCode_table" + " where CodeType = '"+codeType+"'" + " order by CodeName"; ResultSet rs = null; Statement stmt = null; Connection con = null; try{ con = DbPool.getConnection(); stmt = con.createStatement(); rs = stmt.executeQuery(sql); while(rs.next()){ String CodeName = rs.getString(1).trim(); String description = rs.getString(2).trim(); LabelValueBean label = new LabelValueBean(description,CodeName); list.add(label); } }catch(Exception e){ e.printStackTrace(); } finally{ DbPool.closeResultSet(rs); DbPool.closeStatement(stmt); DbPool.closeConnection(con); } return list; } public String getCommonCodeDescription(String codeType,String codeName) { String description = ""; String sql = "select CodeValue from Common_Code" + " where CodeName = '"+codeName+"'" + " and CodeType = '"+codeType+"'"; ResultSet rs = null; Statement stmt = null; Connection con = null; try{ con = DbPool.getConnection(); stmt = con.createStatement(); rs = stmt.executeQuery(sql); while(rs.next()){ description = rs.getString(1); } }catch(java.sql.SQLException sqlEx){ sqlEx.printStackTrace(); }catch(Exception e){ e.printStackTrace(); } finally{ DbPool.closeResultSet(rs); DbPool.closeStatement(stmt); DbPool.closeConnection(con); } return description; } public String getCommonCodeDescription(Connection con,String codeType,int codeName) { String description = ""; String sql = "select CodeValue from Common_Code" + " where CodeName = '"+codeName+"'" + " and CodeType = '"+codeType+"'"; ResultSet rs = null; Statement stmt = null; try{ stmt = con.createStatement(); rs = stmt.executeQuery(sql); while(rs.next()){ description = rs.getString(1); } }catch(java.sql.SQLException sqlEx){ sqlEx.printStackTrace(); } finally{ DbPool.closeResultSet(rs); DbPool.closeStatement(stmt); } return description; }}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -