<rt id="bn8ez"></rt>
<label id="bn8ez"></label>

  • <span id="bn8ez"></span>

    <label id="bn8ez"><meter id="bn8ez"></meter></label>

        明月松間照 清泉石上流


                                            ——— 兵臨城下   貓科動物
    posts - 70, comments - 137, trackbacks - 0, articles - 23
      BlogJava :: 首頁 :: 新隨筆 :: 聯系 :: 聚合  :: 管理

    ?

    1.在server.xml中加入。
    這可以登陸后臺配置。。

    ? <!-- ??configure?DataSource.?Add?the?following?code?into?server.xml?? --> ?
    ?
    ?
    < ?Context? path? =?"?/test?" ??docBase? =?"test?" ??debug? =?"?0?" ?
    reloadable?
    =?"?true?" ??? > ?
    ?
    ?
    ???
    < ?Resource? name? =?"?jdbc/first?" ?
    ???????????????auth?
    =?"?Container?" ?
    ???????????????type?
    =?"?javax.sql.DataSource?" ??? /> ?
    ?
    ???
    < ?ResourceParams? name? =?"?jdbc/first?" ? > ?
    ?????
    < ?parameter? > ?
    ???????
    < ?name? > ?factory? </ ?name? > ?
    ???????
    < ?value? > ?org.apache.commons.dbcp.BasicDataSourceFactory? </ ?value? > ?
    ?????
    </ ?parameter? > ?
    ?
    ?????
    <!-- ??Maximum?number?of?dB?connections?in?pool.?Make?sure?you
    ?????????configure?your?mysqld?max_connections?large?enough?to?handle
    ?????????all?of?your?db?connections.?Set?to??0???for??no?limit.
    ??????????
    --> ?
    ?????
    < ?parameter? > ?
    ???????
    < ?name? > ?maxActive? </ ?name? > ?
    ???????
    < ?value? > ?100? </ ?value? > ?
    ?????
    </ ?parameter? > ?
    ?
    ?????
    <!-- ??Maximum?number?of?idle?dB?connections?to?retain?in?pool.
    ?????????Set?to??0???for??no?limit.
    ??????????
    --> ?
    ?????
    < ?parameter? > ?
    ???????
    < ?name? > ?maxIdle? </ ?name? > ?
    ???????
    < ?value? > ?30? </ ?value? > ?
    ?????
    </ ?parameter? > ?
    ?
    ?????
    <!-- ??Maximum?time?to?wait??for??a?dB?connection?to?become?available
    ?????????in?ms,?in??this??example??10??seconds.?An?Exception?is?thrown??if?
    ??????????this??timeout?is?exceeded.??Set?to??-?1??to?wait?indefinitely.
    ????????Maximum?time?to?wait??for??a?dB?connection?to?become?available
    ?????????in?ms,?in??this??example??10??seconds.?An?Exception?is?thrown??if?
    ??????????this??timeout?is?exceeded.??Set?to??-?1??to?wait?indefinitely.
    ??????????
    --> ?
    ?????
    < ?parameter? > ?
    ???????
    < ?name? > ?maxWait? </ ?name? > ?
    ???????
    < ?value? > ?10000? </ ?value? > ?
    ?????
    </ ?parameter? > ?
    ?
    ?????
    <!-- ??MySQL?dB?username?and?password??for??dB?connections??? --> ?
    ?????
    < ?parameter? > ?
    ??????
    < ?name? > ?username? </ ?name? > ?
    ??????
    < ?value? > ?dbuser? </ ?value? > ?
    ?????
    </ ?parameter? > ?
    ?????
    < ?parameter? > ?
    ??????
    < ?name? > ?password? </ ?name? > ?
    ??????
    < ?value? > ?1234? </ ?value? > ?
    ?????
    </ ?parameter? > ?
    ?
    ?????
    <!-- ??Class?name??for??mm.mysql?JDBC?driver?? --> ?
    ?????
    < ?parameter? > ?
    ????????
    < ?name? > ?driverClassName? </ ?name? > ?
    ????????
    < ?value? > ?com.mysql.jdbc.Driver? </ ?value? > ?
    ?????
    </ ?parameter? > ?
    ?
    ?????
    <!-- ??The?JDBC?connection?url??for??connecting?to?your?MySQL?dB.
    ?????????The?autoReconnect?=?true??argument?to?the?url?makes?sure?that?the
    ?????????mm.mysql?JDBC?Driver?will?automatically?reconnect??if??mysqld?closed?the
    ?????????connection.??mysqld?by??default??closes?idle?connections?after??8??hours.
    ??????????
    --> ?
    ?????
    < ?parameter? > ?
    ???????
    < ?name? > ?url? </ ?name? > ?
    ???????
    < ?value? > ?jdbc:mysql:?//?localhost:3306/test?autoReconnect=true </ value > ?
    ??????
    </ ?parameter? > ?
    ???
    </ ?ResourceParams? > ?
    ?
    ?
    </ ?Context? > ?

    在工程web-xml中加入以下代碼

    ????
    <resource-ref>
    ??????????
    <description>DB?Connection</description>
    ??????????
    <res-ref-name>jdbc/test</res-ref-name>
    ??????????
    <res-type>javax.sql.DataSource</res-type>
    ??????????
    <res-auth>Container</res-auth>
    ??????
    </resource-ref>


    jsp 訪問。。

    導包
    <%@?page?import="java.util.*"%>
    <%@?page?import="java.sql.*"%>
    <%@?page?import="javax.sql.*"%>
    <%@?page?import="javax.naming.*"%>
    <%@?page?import="com.mysql.jdbc.Connection"%>

    訪問代碼


    //建立數據庫連接
    Context?ctx?=?new?InitialContext();
    DataSource?ds?
    =(DataSource)ctx.lookup("java:comp/env/jdbc/test");
    con?
    =?ds.getConnection();
    //創建一個JDBC聲明
    stmt?=?con.createStatement();

    //有了連接。。就可以做很多事了。。


    注意把mysql驅動拷到comcat common/lib下面..


    目標:一天整理一點東西。。雖然簡單。。但記下來還是有好處的。。

    只有注冊用戶登錄后才能發表評論。


    網站導航:
     
    主站蜘蛛池模板: 久久成人永久免费播放| 亚洲国产成人精品不卡青青草原| 亚洲男女性高爱潮网站| 日韩精品极品视频在线观看免费| 国产亚洲自拍一区| 中文字幕a∨在线乱码免费看 | 麻花传媒剧在线mv免费观看| 亚洲国产精品自在在线观看| 99在线免费观看视频| 亚洲精品国产第1页| 91视频国产免费| 亚洲中文字幕无码中文字| 免费的一级黄色片| 婷婷亚洲综合一区二区| 亚洲精品无码你懂的网站| 热久久这里是精品6免费观看| 久久精品国产亚洲av四虎| 91短视频在线免费观看| 亚洲人成人网毛片在线播放| 成人性生交视频免费观看| 黄页视频在线观看免费| 亚洲综合国产一区二区三区| 无码国产精品一区二区免费16| 亚洲国产成人精品无码区在线秒播| 18禁成年无码免费网站无遮挡| 亚洲av永久无码| 亚洲夜夜欢A∨一区二区三区| 色猫咪免费人成网站在线观看 | 免费专区丝袜脚调教视频| 亚洲欧洲AV无码专区| 亚洲AV之男人的天堂| 午夜精品免费在线观看| 在线观看日本亚洲一区| 久久激情亚洲精品无码?V| 2021国内精品久久久久精免费| 久久亚洲精品无码av| 国产AV无码专区亚洲精品| 人妻视频一区二区三区免费| 国产精品无码永久免费888| 亚洲激情校园春色| 亚洲精品国产综合久久一线|