ImageVerifierCode 换一换
你正在下载:

DWR.docx

[预览]
格式:DOCX , 页数:19 ,大小:17.47KB ,
资源ID:9380294      下载积分:3 金币
快捷下载
登录下载
邮箱/手机:
温馨提示:
快捷下载时,用户名和密码都是您填写的邮箱或者手机号,方便查询和重复下载(系统自动生成)。 如填写123,账号就是123,密码也是123。
特别说明:
请自助下载,系统不会自动发送文件的哦; 如果您已付费,想二次下载,请登录后访问:我的下载记录
支付方式: 支付宝    微信支付   
验证码:   换一换

加入VIP,免费下载
 

温馨提示:由于个人手机设置不同,如果发现不能下载,请复制以下地址【https://www.bdocx.com/down/9380294.html】到电脑端继续下载(重复下载不扣费)。

已注册用户请登录:
账号:
密码:
验证码:   换一换
  忘记密码?
三方登录: 微信登录   QQ登录  

下载须知

1: 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。
2: 试题试卷类文档,如果标题没有明确说明有答案则都视为没有答案,请知晓。
3: 文件的所有权益归上传用户所有。
4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
5. 本站仅提供交流平台,并不能对任何下载内容负责。
6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

版权提示 | 免责声明

本文(DWR.docx)为本站会员(b****7)主动上传,冰豆网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。 若此文所含内容侵犯了您的版权或隐私,请立即通知冰豆网(发送邮件至service@bdocx.com或直接QQ联系客服),我们立即给予删除!

DWR.docx

1、DWRDWR整理: 导入:dwr.jar 包script type=text/javascript src=/dwr/util.jsscript type=text/javascript src=/dwr/interface/commDictDWR.js/ 下拉菜单选项Jsp:var status=; / 理赔状态var clmRsn =;function initPage() showSelect(250,status,status); showSelect(310,clmRsn,clmRsn); function showSelect(dictType,id,defaultValue) c

2、ommDictDWR.qryCommDictByType(dictType,function(date) DWRUtil.addOptions(id,:请选择); DWRUtil.addOptions(id,date,id,name); DWRUtil.setValue(id,defaultValue); );Java:public class CommDictDWR /* * 通过字典类型代码取得字段清单 * * param type * 字典类型代码 * return * throws Exception */ public ListMap qryCommDictByType(String

3、 type) throws Exception ListMap list = new ArrayListMap(); Map map = null; DBPool db = null; try String sql = select C_DICT_CDE,C_DICT_NME from TB_COMM_DICT where C_DICT_TYPE=? and C_STATE=1 order by C_DICT_CDE; db = new DBPool(DBConnection.getDBConnection(); db.prepareStatement(sql); db.setString(1

4、, type); ResultSet rs = db.executeQuery(); while (rs.next() map = new HashMap(); map.put(id, rs.getString(C_DICT_CDE); map.put(name, rs.getString(C_DICT_NME); list.add(map); rs.close(); rs = null; catch (Exception e) e.printStackTrace(); throw new Exception(根据字典类型代码查询字典清单出错); finally db.close(); ret

5、urn list; Dwr.xml配置: . Web.xml配置: dwr-invoker /dwr/* DBPool的封装类:import java.io.InputStream;import java.math.BigDecimal;import java.sql.Connection;import java.sql.Date;import java.sql.PreparedStatement;import java.sql.ResultSet;import java.sql.SQLException;import java.sql.Statement;import java.sql.Ti

6、mestamp;import javax.naming.InitialContext;import javax.naming.NamingException;import javax.sql.DataSource;import javax.sql.RowSet;import com.sun.rowset.CachedRowSetImpl;public class DBPool private static DataSource datasource2 = null; private java.sql.Connection conn = null; private ResultSet rs =

7、null; private Statement stmt = null; private PreparedStatement prepstmt = null; public DBPool() /* * 得到数据源连接 * * return * throws Exception * throws SQLException */ private static Connection setConnection() throws Exception Connection connection = null; try if (datasource2 = null) InitialContext init

8、ialcontext = new InitialContext(); / Get DS from JNDI datasource2 = (DataSource) initialcontext.lookup(java:/hacdxDS); connection = datasource2.getConnection(); catch (NamingException namingexception) namingexception.printStackTrace(); throw namingexception; catch (SQLException sqlexception) sqlexce

9、ption.printStackTrace(); throw sqlexception; catch (Exception e) e.printStackTrace(); throw e; return connection; public DBPool(Connection connection) throws SQLException try this.conn = connection; stmt = conn.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY); / 只读的形式取数

10、据 catch (SQLException e) throw e; public DBPool(boolean isConnection) throws Exception try if (isConnection) this.conn = setConnection(); stmt = conn.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY); / 只读的形式取数据 catch (SQLException e) throw e; public void setConnection(C

11、onnection connection) throws SQLException try this.conn = connection; stmt = conn.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY); catch (SQLException e) throw e; /* * function prepareStatement * param sql * String * throws SQLException */ public void prepareStatement(

12、String sql) throws SQLException if (prepstmt != null) prepstmt.close(); prepstmt = null; if (null = conn) System.out.println(连接为空!); prepstmt = conn.prepareStatement(sql, ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY); /* * function prepareStatement * param sbSql * StringBuffer * thr

13、ows SQLException */ public void prepareStatement(StringBuffer sbSql) throws SQLException if (prepstmt != null) prepstmt.close(); prepstmt = null; if (null = conn) System.out.println(连接为空!); prepstmt = conn.prepareStatement(sbSql.toString(), ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ON

14、LY); /* * function get a connection * * return Connection */ public Connection getConnection() throws SQLException return conn; /* * function prepareStatement * param sql * String * param resultSetType * int * param resultSetConcurrency * int * throws SQLException */ public void prepareStatement(Str

15、ing sql, int resultSetType, int resultSetConcurrency) throws SQLException prepstmt = conn.prepareStatement(sql, resultSetType, resultSetConcurrency); /* * function executeQuery * param sql * String * throws SQLException * return ResultSet */ public ResultSet executeQuery(String sql) throws SQLExcept

16、ion if (stmt != null) return stmt.executeQuery(sql); else return null; /* * function executeQuery * throws SQLException * return ResultSet */ public RowSet executeQuery() throws SQLException CachedRowSetImpl rowset = new CachedRowSetImpl(); ResultSet rs = null; if (prepstmt != null) rs = prepstmt.ex

17、ecuteQuery(); rowset.populate(new ResultSetWrapper(rs); rs.close(); prepstmt.close(); rs = null; prepstmt = null; else return null; return rowset; public void executeSql(String sql) throws SQLException if (stmt != null) stmt.execute(sql.trim(); else throw new SQLException(数据库连接失败); /* * function exe

18、cuteUpdate * param sql * String * throws SQLException */ public void executeUpdate(String sql) throws SQLException if (stmt != null) stmt.executeUpdate(sql); /* * function executeUpdate * throws SQLException */ public int executeUpdate() throws SQLException int i = -1; if (prepstmt != null) i = prep

19、stmt.executeUpdate(); prepstmt.close(); prepstmt = null; return i; public void execute() throws SQLException if (prepstmt != null) prepstmt.execute(); prepstmt.close(); prepstmt = null; /* * function executeUpdate * throws SQLException */ public void executeBatch() throws SQLException if (prepstmt !

20、= null) prepstmt.executeBatch(); /* * function addBatch * param value * String * throws SQLException */ public void addBatch(String value) throws SQLException prepstmt.addBatch(value); public void addBatch() throws SQLException prepstmt.addBatch(); public void clearBatch() throws SQLException prepst

21、mt.clearBatch(); public void prepstmtClose() throws SQLException prepstmt.close(); public void setString(int index, String value) throws SQLException prepstmt.setString(index, value); public void setObject(int index, Object value) throws SQLException prepstmt.setObject(index, value); public void set

22、Int(int index, int value) throws SQLException prepstmt.setInt(index, value); public void setBigDecimal(int index, BigDecimal value) throws SQLException prepstmt.setBigDecimal(index, value); public void setBoolean(int index, boolean value) throws SQLException prepstmt.setBoolean(index, value); /* * f

23、unction setDate * param index * int * param value * Date * throws SQLException */ public void setDate(int index, Date value) throws SQLException prepstmt.setDate(index, value); /* * function setLong * param index * int * param value * long * throws SQLException */ public void setLong(int index, long

24、 value) throws SQLException prepstmt.setLong(index, value); /* * function setFloat * param index * int * param value * float * throws SQLException */ public void setFloat(int index, float value) throws SQLException prepstmt.setFloat(index, value); /* * function setBytes * param index * int * param v

25、alue * byte * throws SQLException */ public void setBytes(int index, byte value) throws SQLException prepstmt.setBytes(index, value); /* * function setBinaryStream * param index * int * param value * InputStream * param len * int * throws SQLException */ public void setBinaryStream(int index, InputStream value, int len) throws S

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1