现在的位置: 首页 > 综合 > 正文

在Resin环境采用PHP链接MySQL数据库

2012年12月14日 ⁄ 综合 ⁄ 共 944字 ⁄ 字号 评论关闭

  下面将提供一些简单的步骤,教你如何在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了。

抱歉!评论已关闭.