Section | ||||||||
---|---|---|---|---|---|---|---|---|
|
...
There is an alternate approach that defines the database connection in the application container (Tomcat if you are using the frevvo-tomcat bundle) instead of inside the database connector. To use this approach:
Edit Edit frevvo\tomcat\conf\Catalina\localhost\context.xml.default file in your v7.2+ installation to add the "frevvo.connectors.database.configuration' and Resource Name parameters if they are not already defined.
Code Block Define a <resource> as shown below. The XML samples below assume a MySql database driver. You will need to replace this sample values to match your database type.
This is the format of the <resource> element in context.xml.default.
Code Block <Resource name="jdbc/mystore_ds" auth="Container" factory="org.apache.commons.dbcp.BasicDataSourceFactory" driverClassName="com.mysql.jdbc.Driver" username="YOUR database user HERE" password="YOUR database password HERE" type="javax.sql.DataSource" url="jdbc:mysql://localhost/mystore?autoconnect=true"/>
A sample context.xml.default file for MySQL is shown belowCode Block <Context swallowOutput="true" unloadDelay="40000" useHttpOnly="true"> <Manager className="org.apache.catalina.session.PersistentManager" saveOnRestart="false"> <Store className="org.apache.catalina.session.FileStore"/> </Manager> <Parameter name="insight.server.url" value="http://localhost:8983/solr" override="false"/> <Parameter name="frevvo.connectors.database.configuration" value= "<path to the configuration.xml file>" override="false"/> <Resource name="jdbc/<your database name>" auth="Container" driverClassName="com.mysql.jdbc.Driver" username="<your database user>" password="<your database password>" type="javax.sql.DataSource" url="jdbc:mysql://localhost/<your queryset name>?autoconnect=true"/> </Context>
Replace the <resource-def> element in your configuration.xml with a <resource-ref> element as shown below.
Code Block <resource-ref> <description>MySQL Customers</description> <res-ref-name>jdbc/mystore_ds</res-ref-name> <res-type>javax.sql.DataSource</res-type> <res-auth>Container</res-auth> </resource-ref>
- Verify that the resource-ref is defined in your configuration.xml file for each queryset.
- Alternatively, you can copy frevvo\tomcat\conf\Catalina\localhost\context.xml.default and dbconfig\configuration.xml to appropriate location in the v7.2+ tomcat bundle.
Configure the v2.5 connector using the 2.4 configuration files in Standalone mode
...
Examples of Datasource Definitions in the configuration.xml file
Examples of datasources that can be used in the configuration.xml file for some common databases are shown below. Always check with your database administrator or the documentation for your database driver to verify the details are correct.
MySQL example
A mySql database named "test" running on localhost on the default port when the login for user "root" requires no password:
...
Check with your database administrator or the documentation for your database drive driver for details on the correct database URL format.
...