📄 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 + -