在Resin環境採用PHP連結MySQL資料庫

來源:互聯網
上載者:User

  下面將提供一些簡單的步驟,教你如何在Resin下使用PHP與mysql資料庫的串連操作。關於PHP怎麼在Resin下運行,請見我的另一篇文章,在Resin中使用PHP。

步驟如下:

 一、下載MySql的jdbc驅動

可以從http://www.mysql.com/products/connector/j/ 下載。

 二、配置 resin安裝目錄/conf/resin.conf 檔案

在檔案中加入下面的部分:

        <database>
          <jndi-name>jdbc/mysql</jndi-name>
          <driver type="org.gjt.mm.mysql.Driver">
            <url>jdbc:mysql://localhost:3306/test</url>
            <user></user>
            <password></password>
           </driver>
           <prepared-statement-cache-size>8</prepared-statement-cache-size>
           <max-connections>20</max-connections>
           <max-idle-time>30s</max-idle-time>
         </database>

三、修改 /Web-INF/web.xml檔案加入資料配置引用

<web-app xmlns="http://caucho.com/ns/resin">
         <servlet-mapping url-pattern="*.php"
                   servlet-class="com.caucho.quercus.servlet.QuercusServlet">
    <init>
      <compile>false</compile>
      <database>jdbc/mysql</database>
    </init>
  </servlet-mapping>
</web-app>

通過以上步驟你可以使用mysql了。

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.