Chinaorg

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

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

          Posted on 2006-10-09 01:05 chinaorg 閱讀(181) 評論(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();


          主站蜘蛛池模板: 五寨县| 八宿县| 库车县| 凤翔县| 许昌市| 泊头市| 娱乐| 漯河市| 达拉特旗| 米林县| 福清市| 德昌县| 巴林左旗| 宜宾县| 康保县| 香河县| 虹口区| 松溪县| 阳信县| 扶风县| 思茅市| 田阳县| 扶绥县| 宁德市| 阜宁县| 乐东| 攀枝花市| 佛山市| 六安市| 营口市| 中卫市| 普宁市| 遂昌县| 阿拉尔市| 若羌县| 荣昌县| 石楼县| 巴中市| 楚雄市| 徐水县| 闽侯县|