当前位置: 技术问答>java相关
struts datasource 设置问题,请教高手
来源: 互联网 发布时间:2017-04-01
本文导语: 在struts的struts-config.xml里可以设置data-source, 设置完以后,怎么在程序里调用这个datasource呢? | 在Action类里: public ActionForward perform(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpSe...
在struts的struts-config.xml里可以设置data-source,
设置完以后,怎么在程序里调用这个datasource呢?
设置完以后,怎么在程序里调用这个datasource呢?
|
在Action类里:
public ActionForward perform(ActionMapping mapping,
ActionForm form,
HttpServletRequest request,
HttpServletResponse response)
throws IOException, ServletException{
DataSource dataSource =servlet.findDataSource(null);
Connection conn =dataSource.getConnection();
…………
public ActionForward perform(ActionMapping mapping,
ActionForm form,
HttpServletRequest request,
HttpServletResponse response)
throws IOException, ServletException{
DataSource dataSource =servlet.findDataSource(null);
Connection conn =dataSource.getConnection();
…………