DWRWord下载.docx
- 文档编号:22516356
- 上传时间:2023-02-04
- 格式:DOCX
- 页数:19
- 大小:17.47KB
DWRWord下载.docx
《DWRWord下载.docx》由会员分享,可在线阅读,更多相关《DWRWord下载.docx(19页珍藏版)》请在冰豆网上搜索。
,status);
showSelect('
310'
clmRsn'
clmRsn);
}
functionshowSelect(dictType,id,defaultValue){
commDictDWR.qryCommDictByType(dictType,function(date){
DWRUtil.addOptions(id,{"
"
:
请选择"
});
DWRUtil.addOptions(id,date,"
id"
"
name"
);
DWRUtil.setValue(id,defaultValue);
});
}
Java:
publicclassCommDictDWR{
/**
*通过字典类型代码取得字段清单
*
*@paramtype
*字典类型代码
*@return
*@throwsException
*/
publicList<
Map<
String,String>
qryCommDictByType(Stringtype)throwsException{
List<
list=newArrayList<
();
Map<
map=null;
DBPooldb=null;
try{
Stringsql="
selectC_DICT_CDE,C_DICT_NMEfromTB_COMM_DICTwhereC_DICT_TYPE=?
andC_STATE='
1'
orderbyC_DICT_CDE"
db=newDBPool(DBConnection.getDBConnection());
db.prepareStatement(sql);
db.setString(1,type);
ResultSetrs=db.executeQuery();
while(rs.next()){
map=newHashMap<
map.put("
rs.getString("
C_DICT_CDE"
));
C_DICT_NME"
list.add(map);
}
rs.close();
rs=null;
}catch(Exceptione){
e.printStackTrace();
thrownewException("
根据字典类型代码查询字典清单出错"
}finally{
db.close();
}
returnlist;
Dwr.xml配置:
?
xmlversion="
1.0"
encoding="
UTF-8"
!
DOCTYPEdwrPUBLIC"
-//GetAheadLimited//DTDDirectWebRemoting2.0//EN"
"
http:
//www.getahead.ltd.uk/dwr/dwr20.dtd"
dwr>
<
init>
/init>
allow>
<
createcreator="
new"
javascript="
commDictDWR"
<
paramname="
class"
value="
mon.CommDictDWR"
/>
includemethod="
qryCommDictByTypeName"
qryCommDictByType"
qryCommDict"
qryAllDictType"
qryDictConf"
qryAllItemType"
/create>
......
convertconverter="
bean"
match="
mset.dto.CommDict"
include"
value="
dictCde,dictNme,id,name"
/convert>
/allow>
/dwr>
Web.xml配置:
servlet-mapping>
servlet-name>
dwr-invoker<
/servlet-name>
url-pattern>
/dwr/*<
/url-pattern>
/servlet-mapping>
DBPool的封装类:
importjava.io.InputStream;
importjava.math.BigDecimal;
importjava.sql.Connection;
importjava.sql.Date;
importjava.sql.PreparedStatement;
importjava.sql.ResultSet;
importjava.sql.SQLException;
importjava.sql.Statement;
importjava.sql.Timestamp;
importjavax.naming.InitialContext;
importjavax.naming.NamingException;
importjavax.sql.DataSource;
importjavax.sql.RowSet;
importcom.sun.rowset.CachedRowSetImpl;
publicclassDBPool{
privatestaticDataSourcedatasource2=null;
privatejava.sql.Connectionconn=null;
privateResultSetrs=null;
privateStatementstmt=null;
privatePreparedStatementprepstmt=null;
publicDBPool(){
/**
*得到数据源连接
*@throwsSQLException
privatestaticConnectionsetConnection()throwsException{
Connectionconnection=null;
if(datasource2==null){
InitialContextinitialcontext=newInitialContext();
//GetDSfromJNDI
datasource2=(DataSource)initialcontext.lookup("
java:
/hacdxDS"
connection=datasource2.getConnection();
}catch(NamingExceptionnamingexception){
namingexception.printStackTrace();
thrownamingexception;
}catch(SQLExceptionsqlexception){
sqlexception.printStackTrace();
throwsqlexception;
throwe;
returnconnection;
publicDBPool(Connectionconnection)throwsSQLException{
this.conn=connection;
stmt=conn.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,ResultSet.CONCUR_READ_ONLY);
//只读的形式取数据
}catch(SQLExceptione){
publicDBPool(booleanisConnection)throwsException{
if(isConnection){
this.conn=setConnection();
stmt=conn.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,ResultSet.CONCUR_READ_ONLY);
//只读的形式取数据
publicvoidsetConnection(Connectionconnection)throwsSQLException{
*@functionprepareStatement
*@paramsql
*String
publicvoidprepareStatement(Stringsql)throwsSQLException{
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);
*@paramsbSql
*StringBuffer
publicvoidprepareStatement(StringBuffersbSql)throwsSQLException{
prepstmt=conn.prepareStatement(sbSql.toString(),ResultSet.TYPE_SCROLL_INSENSITIVE,ResultSet.CONCUR_READ_ONLY);
*functiongetaconnection
*@returnConnection
publicConnectiongetConnection()throwsSQLException{
returnconn;
*@paramresultSetType
*int
*@paramresultSetConcurrency
publicvoidprepareStatement(Stringsql,intresultSetType,intresultSetConcurrency)throwsSQLException{
prepstmt=conn.prepareStatement(sql,resultSetType,resultSetConcurrency);
*@functionexecuteQuery
*@returnResultSet
publicResultSetexecuteQuery(Stringsql)throwsSQLException{
if(stmt!
returnstmt.executeQuery(sql);
}else{
returnnull;
publicRowSetexecuteQuery()throwsSQLException{
CachedRowSetImplrowset=newCachedRowSetImpl();
ResultSetrs=null;
rs=prepstmt.executeQuery();
rowset.populate(newResultSetWrapper(rs));
returnrowset;
publicvoidexecuteSql(Stringsql)throwsSQLException{
stmt.execute(sql.trim());
thrownewSQLException("
数据库连接失败"
*@functionexecuteUpdate
publicvoidexecuteUpdate(Stringsql)throwsSQLException{
stmt.executeUpdate(sql);
publicintexecuteUpdate()throwsSQLException{
inti=-1;
i=prepstmt.executeUpdate();
returni;
publicvoidexecute()throwsSQLException{
prepstmt.execute();
publicvoidexecuteBatch()throwsSQLException{
prepstmt.executeBatch();
*@functionaddBatch
*@paramvalue
publicvoidaddBatch(Stringvalue)throwsSQLException{
prepstmt.addBatch(value);
publicvoidaddBatch()throwsSQLException{
prepstmt.addBatch();
publicvoidclearBatch()throwsSQLException{
prepstmt.clearBatch();
publicvoidprepstmtClose()throwsSQLException{
prepstmt.close();
publicvoidsetString(intindex,Stringvalue)throwsSQLException{
prepstmt.setString(index,value);
publicvoidsetObject(intindex,Objectvalue)throwsSQLException{
prepstmt.setObject(index,value);
publicvoidsetInt(intindex,intvalue)throwsSQLException{
prepstmt.setInt(index,value);
publicvoidsetBigDecimal(intindex,BigDecimalvalue)throwsSQLException{
prepstmt.setBigDecimal(index,value);
publicvoidsetBoolean(intindex,booleanvalue)throwsSQLException{
prepstmt.setBoolean(index,value);
*@functionsetDate
*@paramindex
*Date
publicvoidsetDate(intindex,Datevalue)throwsSQLException{
prepstmt.setDate(index,value);
*@functionsetLong
*long
publicvoidsetLong(intindex,longvalue)throwsSQLException{
prepstmt.setLong(index,value);
*@functionsetFloat
*float
publicvoidsetFloat(intindex,floatvalue)throwsSQLException{
prepstmt.setFloat(index,value);
*@functionsetBytes
*byte[]
publicvoidsetBytes(intindex,byte[]value)throwsSQLException{
prepstmt.setBytes(index,value);
*@functionsetBinaryStream
*InputStream
*@paramlen
publicvoidsetBinaryStream(intindex,InputStreamvalue,intlen)throwsS
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- DWR
