下面将提供一些简单的步骤,教你如何在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了。
本文介绍在Resin环境中使用PHP连接MySQL数据库的具体步骤,包括下载MySql的jdbc驱动、配置resin.conf文件及web.xml文件等。通过这些步骤可以实现PHP与MySQL的有效连接。
337

被折叠的 条评论
为什么被折叠?



