精彩专题推荐:建站之入门课 建站之必修课 建站之关键课 网站价值所在 流量提高专题 css+div 标准 个人网站打造全过程
返回建站学首页
导航:
建站首页 | 网站设计 | 网站开发 | 网站运营 | 网页软件 | 建站指南 | 搜索优化 | 图像处理 | 视频教程 | 书籍教程 | 建站专题
当前位置:首页>网站开发>xml教程>正文

在Web应用中使用XML文件配置数据源


来源: 时间:06-12-30 点击: 点击这里收藏本文

    
    <title>My JSP 'oracleDataSourceDemo.jsp' starting page</title>
    
    <meta http-equiv="pragma" content="no-cache">
    <meta http-equiv="cache-control" content="no-cache">
    <meta http-equiv="expires" content="0">
    <meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
    <meta http-equiv="description" content="This is my page">
    
    <!--
    <link rel="stylesheet" type="text/css" href="styles.css">
    -->
  </head>
  
  <body>
    This is my JSP page. <br>
    this  is  a  test  of  getting  the  connection   
    from  a orace  datasource    configured   using  the  XML   files  
    <br>
    <%
        Context  ctx=new InitialContext();
        DataSource  ds=(DataSource)ctx.lookup(OracleDataSourceListener.JNDI_NAME);
        Connection  con=ds.getConnection();
           out.println(con);
    %>
  </body>
</html>
(八)    测试结果
(1)    MSSQL  的测试结果为:
This is my JSP page. 
this is a test of getting the connection from a orace datasource configured using the XML files 
oracle.jdbc.driver.OracleConnection@143073a
(2)    Oracle的测试结果为:
This is my JSP page. 
org.apache.commons.dbcp.PoolableConnection@18facfb

以上程序均调试通过。如果还有问题,和我联系
zhyiwww@163.com.

总结:
(1)    编写数据源配置文件??XML文件
(2)    编写解析类
(3)    编写侦听器类
(4)    在Web.xml中配置数据源
(5)    测试数据源

在本例中,仅仅谈到实现,不涉及到其设计问题。仅供参考。
9 7 3 11 4 8 :

  把此文章收藏到:          
广而告之
文章搜索
  • Google JZxue.Com

关于我们 | 联系我们 | 友情链接 | 网站地图
Copyright © 2005 - 2006 建站学 All rights reserved.