Date: 2004-07-09T04:18:20 Editor: DerekLastname <[EMAIL PROTECTED]> Wiki: Cocoon Wiki Page: ConnectionPooling URL: http://wiki.apache.org/cocoon/ConnectionPooling
no comment Change Log: ------------------------------------------------------------------------------ @@ -1,6 +1,6 @@ === Installing a [http://java.sun.com/products/jdbc/ JDBC] driver === -Consult the database documentation to find out where an appropriate [http://java.sun.com/products/jdbc/ JDBC] driver can be obtained for the database server that'll be used with Cocoon. Or see [:Specificdatabaseconnections]. Sun also mantains a [http://industry.java.sun.com/products/jdbc/drivers list of drivers]. +Consult the database documentation to find out where an appropriate [http://java.sun.com/products/jdbc/ JDBC] driver can be obtained for the database server that'll be used with Cocoon. Or see [:SpecificDatabaseConnections]. Sun also mantains a [http://industry.java.sun.com/products/jdbc/drivers list of drivers]. Drivers are usually packaged as zip or jar files. Installation is simply a matter of ensuring that the archive containing the classes is correctly configured in the CLASSPATH. @@ -13,11 +13,11 @@ The {{{extra-classpath}}} parameter is normally commented out. Simply remove the comments, leaving the following: -{{{ -<init-param> - <param-name>extra-classpath</param-name> - <param-value>WEB-INF/extra-classes1:/[YOU-ABSOLUTE-PATH-TO]/own.jar</param-value> -</init-param> +{{{ +<init-param> + <param-name>extra-classpath</param-name> + <param-value>WEB-INF/extra-classes1:/[YOU-ABSOLUTE-PATH-TO]/own.jar</param-value> +</init-param> }}} Note that the absolute path to the database driver should be specified. @@ -30,20 +30,20 @@ To ensure that the appropriate classes get loaded when Cocoon starts, the class name for the JDBC driver should be added to the {{{load-class}}} parameter in the $COCOON_HOME/WEB-INF/web.xml configuuration file. -{{{ -<init-param> - <param-name>load-class</param-name> - <param-value> - <!-- For IBM WebSphere: --> - com.ibm.servlet.classloader.Handler - - <!-- For JDBC-ODBC Bridge: --> - sun.jdbc.odbc.JdbcOdbcDriver - - <!-- For Interbase DBMS: --> - interbase.interclient.Driver - </param-value> -</init-param> +{{{ +<init-param> + <param-name>load-class</param-name> + <param-value> + <!-- For IBM WebSphere: --> + com.ibm.servlet.classloader.Handler + + <!-- For JDBC-ODBC Bridge: --> + sun.jdbc.odbc.JdbcOdbcDriver + + <!-- For Interbase DBMS: --> + interbase.interclient.Driver + </param-value> +</init-param> }}} Classes should be referenced using their fully-specified names. Consult the driver documentation for the correct class name. @@ -54,21 +54,21 @@ Datasources such as database connections are configured within the {{{datasource}}} element as follows: -{{{ -<datasources> -... - <jdbc name="pool-name"> - <pool-controller min="1" max="5"/> - <auto-commit>true|false</auto-commit> - <dburl>JDBC-connection-string</dburl> - <user>database-username</user> - <password>database-password</password> - </jdbc> -... -</datasources> +{{{ +<datasources> +... + <jdbc name="pool-name"> + <pool-controller min="1" max="5"/> + <auto-commit>true|false</auto-commit> + <dburl>JDBC-connection-string</dburl> + <user>database-username</user> + <password>database-password</password> + </jdbc> +... +</datasources> }}} -Note that because connection pools are configured in the {{{cocoon.xconf}}} config file, the application server must be restarted to alter these configuration parameters. Unlike the [:sitemap] which can be re-loaded if it changes, the main configuration file is only read when Cocoon initialises. +Note that because connection pools are configured in the {{{cocoon.xconf}}} config file, the application server must be restarted to alter these configuration parameters. Unlike the [:Sitemap] which can be re-loaded if it changes, the main configuration file is only read when Cocoon initialises. The elements in the above examine have the following responsibilities: @@ -91,8 +91,8 @@ Firstly the Cocoon {{{root.log}}} file will contain a log entry similar to the following: -{{{ -(Unknown-URI) Unknown-thread/CocoonServlet: Trying to load class: org.hsqldb.jdbcDriver +{{{ +(Unknown-URI) Unknown-thread/CocoonServlet: Trying to load class: org.hsqldb.jdbcDriver }}} If there is a stack trace following this entry, for example a {{{ClassNotFoundException}}}, check that the CLASSPATH has been configured correctly. @@ -106,13 +106,13 @@ The class must implement the ((Composable)) interface, and is passed the {{{ComponentManager}}} automatically. The !DataSource can then be cached for later use -{{{ -... -ComponentSelector selector = - (ComponentSelector) manager.lookup(Roles.DB_CONNECTION); -DataSourceComponent datasource = (DataSourceComponent) -selector.select("my_pool"); -... +{{{ +... +ComponentSelector selector = + (ComponentSelector) manager.lookup(Roles.DB_CONNECTION); +DataSourceComponent datasource = (DataSourceComponent) +selector.select("my_pool"); +... }}} === Using the Pool in flowscript ===
