Chinaorg

          于千萬人之中,遇見你所遇見的人;于千萬年之中,時間的無涯荒野里,沒有早一步,也沒有晚一步,剛巧趕上了
          我不去想是否能夠成功,既然選擇了遠方,便只顧風雨兼程; 我不去想,身后會不會襲來寒風冷雨,既然目標是地平線,留給世界的只能是背影
          posts - 20, comments - 6, trackbacks - 0, articles - 0

          配置連接池(終于弄好了~~)

          Posted on 2006-10-09 01:05 chinaorg 閱讀(175) 評論(0)  編輯  收藏 所屬分類: JAVA/JSP

          server.xml

          ?<Context path="/bookstore" docBase="bookstore" debug="0"?????reloadable="true">

          ?????<Resource
          ?????????name="jdbc/BookDB"?
          ?????????auth="Container"
          ?????????type="javax.sql.DataSource"
          ?????????driverClassName="com.mysql.jdbc.Driver"?
          ?????????maxActive="100"
          ?????????maxIdle="30" maxWait="10000"
          ?????????url="jdbc:mysql://localhost:3306/bookdb?autoReconnect=true"
          ?????????username="dbuser"?
          ?????????password="1234"?
          ?????????removeAbandoned="true"/>

          ????</Context>




          web.xml

          <?xml version="1.0" encoding="UTF-8"?>
          ?? <web-app>
          ??? <welcome-file-list>
          ??????? <welcome-file>Dbjsp1.jsp</welcome-file>
          ??????? <welcome-file>index.htm</welcome-file>
          ??????? <welcome-file>index.jsp</welcome-file>
          ??? </welcome-file-list>
          ?<resource-ref>
          ??<description>DB connection</description>
          ??<res-ref-name>jdbc/BookDB</res-ref-name>
          ??<res-type>javax.sql.Datasource</res-type>
          ??<res-auth>Container</res-auth>
          ??<res-sharing-scope>Shareable</res-sharing-scope>
          ?</resource-ref>
          </web-app>



          //數據庫連接代碼

          ??Connection con;
          ??Statement stmt;
          ??ResultSet rs;
          ??
          ??Context ctx=new InitialContext();
          ??DataSource ds=(DataSource)ctx.lookup("java:comp/env/jdbc/BookDB");
          ??con=ds.getConnection();
          ??
          ??stmt=con.createStatement();


          主站蜘蛛池模板: 德化县| 平塘县| 昌宁县| 双流县| 曲周县| 娱乐| 高平市| 门头沟区| 农安县| 黄陵县| 隆安县| 大田县| 新绛县| 桂平市| 樟树市| 台湾省| 舞钢市| 巴彦淖尔市| 武邑县| 筠连县| 阿拉善左旗| 重庆市| 吉水县| 衡阳市| 略阳县| 和林格尔县| 习水县| 子长县| 阳城县| 大同市| 肥乡县| 互助| 花莲市| 凤庆县| 内江市| 光山县| 新绛县| 于田县| 永丰县| 玉屏| 东兴市|