Struts DataSource
来源:互联网 发布:淘宝多少天后自动付款 编辑:程序博客网 时间:2024/05/21 03:29
1 、在struts-config.xml下
<data-sources >
<data-source key="DataSource">
<set-property property="minCount" value="2" />
<set-property property="password" value="spring" />
<set-property property="maxCount" value="10" />
<set-property property="user" value="spring" />
<set-property property="driverClass" value="oracle.jdbc.driver.OracleDriver" />
<set-property property="description" value="datasource" />
<set-property property="url" value="jdbc:oracle:thin:@it10:1521:SP" />
<set-property property="autoCommit" value="false" />
<set-property property="readOnly" value="false" />
<set-property property="loginTimeout" value="" />
</data-source>
2、在Action下
public ActionForward execute(
ActionMapping mapping,
ActionForm form,
HttpServletRequest request,
HttpServletResponse response) throws Exception {
DataSource dataSource=this.getDataSource(request,Constants.DATASOURCE_KEY);
Connection connection=dataSource.getConnection(); //取得Connection
HelpBean helpBean=new HelpBean();
Vector infovv=helpBean.getItemInfos(connection);
}
3、Constants.java
package com.tek.david.dataBase.pool;
/**
* @author qianzh
*
* TODO To change the template for this generated type comment go to
* Window - Preferences - Java - Code Style - Code Templates
*/
public class Constants {
public static String DATASOURCE_KEY="DataSource";
}
4、建立HelpBean
加入方法
public Vector getItemInfos(Connection conn) throws Exception{
Vector ret=new Vector();
Statement stmt=conn.createStatement();
String sql="select * from test";
ResultSet rs=stmt.executeQuery(sql);
while(rs.next()){
ItemBean itemBean=new ItemBean();
InfoBean infoBean=new InfoBean();
infoBean.setUser_id(rs.getString(1));
infoBean.setUsername(rs.getString(2));
infoBean.setPassword(rs.getString(3));
infoBean.setNeedqty(rs.getString(4));
itemBean.setInfoBean(infoBean);
itemBean.setIsqty("");
ret.add(itemBean);
}
rs.close();
stmt.close();
conn.close();
return ret;
}
- Struts DataSource
- Struts datasource 配置问题
- Struts中的DataSource配置
- Struts中的DataSource配置
- struts下的datasource配置
- [Struts] Don't use Datasource of Struts.
- MyEclipse在Struts中配置DataSource
- 在非struts程序中使用struts的datasource
- DataSource
- DataSource
- datasource
- dataSource
- dataSource
- myeclipse在struts中配置mysql的datasource
- struts中数据源(DataSource)的配置与使用
- myeclipse在struts中配置mysql的datasource
- struts-config.xml中datasource配置說明
- 关于用myeclipse在struts-config.xml中配置datasource的注意事项
- 遍历ArrayList易犯错误
- 每个开发人员现在应该下载的十种必备工具
- .net控件FreeTextBox使用方法
- 为freetextbox1.6.5上传图片加上水印
- FreeTextBox实现机制
- Struts DataSource
- FreeTextBox的ToolbarButton整理
- 针对SQL INJECTION的SQL SERVER安全设置初级篇
- [转载自nylx的Blog]看看老外的开源项目
- SQL SERVER与ACCESS、EXCEL的数据转换
- Longhorn明年5月完成 微软将推7个版本
- Internet Explorer 6 中的 CSS 增强功能
- 2005年最具钱途的人才:软件研发炙手可热
- ASP.Net实现验证码