⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 db-config.xtp

📁 解压在c盘
💻 XTP
字号:
<s1 title="Database Configuration"><p>Resin's database configuration pulls configuration out ofyour application and into the configuration files where it belongs.The configuration lets you create any number of named database pools.</p><example title='resin.conf'>&lt;caucho.com&gt;&lt;resource-ref>  &lt;res-ref-name>jdbc/test_db&lt;/res-ref-name>  &lt;res-type>javax.sql.DataSource&lt;/res-type>  &lt;init-param driver-name="org.gjt.mm.mysql.Driver"/>  &lt;init-param url="jdbc:mysql://localhost:3306/test"/>  &lt;init-param user="ferg"/>  &lt;init-param password="changeit"/>&lt;/resource-ref>&lt;/caucho.com&gt;</example><p>The <var/resource-ref/> configuration is more general than justconfiguring database pools.  So it needs <var/res-type/> of<var/javax.sql.DataSource/> to say that it's configuring a databasepool and not, say, an imap client.</p><p>Since the database configuration puts the initialized pool in a JNDIContext, the resource-ref needs to specify where in the JNDI tree thedata source belongs.  <var/res-ref-name/> tells Resin where to putthe data source in the JNDI tree.  The previous example used<var/InitialContext().lookup("...")/> to grab the data source from the tree.Although JNDI is slightly more complicated, using it means yourcode can be independent of the database configuration.</p><deftable title="Configuration Tags"><tr><td>resource-ref<td>the standard configuration for datasources.  (It can also be used to initialize other beans.)<tr><td>res-ref-name<td>where to attach the data source in theJNDI namespace.  In the example, the final name willbe <var/java:comp/env/jdbc/test_db/>.<tr><td>res-type<td>The type of the resource we're configuring.In this case, we're configuring a database pool, so theresource type is <var/javax.sql.DataSource/>.<tr><td>init-param<td>Lets you configure the database pool andconfigure arbitrary properties of the JDBC driver.  Any beansetter can be used.  So <var/driver-name/> translatesinto <var/setDriverName/>.  You can look at <var/com.caucho.sql.DBPool/>for the list of bean attributes in the pooling driver.<tr><td>driver-name<td>Sets <var/DBPool.setDriverName/>.  Selects theJava class of the JDBC driver.  You'll need to look at your driver'sdocumentation for the class name.<tr><td>url<td>Sets <var/DBPool.setURL/>.  Selects the JDBC URL forthe datasource.  Again, you'll need to look at your driver's documentationfor this value.<tr><td>user<td>the name of the database user<tr><td>password<td>the database password</deftable><p>Some JDBC drivers may need additional properties, and others don'tneed the <var/user/> and <var/password/> configuration.  You canlook at <var/com.caucho.sql.DBPool/> for the list of pooling attributesand consult your JDBC driver documentation.</p><p>Any property can be configured with the <var/init-param/> entries.The parameter name is converted to a <var/setXXX/> method using standardbean conventions.  If the <var/setXXX/> is not in the pool, theresource-ref configuration will call <var/setProperty/> to set anydriver property.  When Resin calls setProperty, it passes the exactkey given in the init-param element, without bean translations.</p><s2 title='Classpath'><p>You will need to add your JDBC driver to the classpath before startingResin.  There are several methods:</p><ol><li>Add the driver to the CLASSPATH environment variable.<li>Start Resin with a -classpath argument including the driver.<li>Put the jar file in resin-2.0.x/lib.</ol><p>You can see the classpath Resin is using by starting it with the<var/-verbose/> option:</p><example>unix> <var/httpd.sh -verbose/></example></s2></s1>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -