Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

This is the format of the <resource-def> element:<pre>

Code Block
<resource-def>

...


    <url>YOUR database Url HERE</url>   
    <driver>YOUR driver HERE</driver>
    <user>YOUR database user HERE</user>
    <password>YOUR password HERE</password>
</resource-def>

...

Note

 NOTE: Under most operating systems the database connector will automatically reload the configuration.xml as soon as you edit and save changes, without the need to restart tomcat or the database connector itself.

However under Mac OS auto reload does not work. To ensure that the change is reflected restart tomcat manually via the stop/start frevvo scripts.

...

mySQL example

A mySql database named "test" running on localhost on the default port when the login for user "root" requires no password:<pre>

Code Block
<resource-def>

...


    <url>jdbc:mysql://localhost/test</

...

url>    
    <driver>com.mysql.jdbc.Driver</driver>

...


    <user>root</user>

...


    <password></password>

...


</resource-def>

...

A database URL is a Universal Resource Locator (URL) that specifies a particular type of database server (compatible with the JDBC driver you installed or was pre-installed in database\WEB-INF\lib) and a particular host.  In addition you can also specify the database name to use for the connection.

...

Here is an example that connects to an '''HSQLDB driver'''.<pre>

Code Block
<resource-def>

...


    <url>jdbc:hsqldb:file:mystore</

...

url>       
    <driver>org.hsqldb.jdbcDriver</driver>

...


    <user>sa</user>

...


    <password></password>

...


</resource-def>

...

The following examples are for several common databases. Please consult your database documentation and version for the exact configuration settings.

...

Here is an example that connects to a '''SQL Server driver'''.<pre>

Code Block
<resource-def>

...


    <url>jdbc:sqlserver://192.168.1.102;DatabaseName=mystore;</

...

url>       
    <driver>com.microsoft.sqlserver.jdbc.SQLServerDriver</driver>

...


    <user>yourUser</user>

...


    <password>yourPassword</password>

...


</resource-def>

...

SQL jTDS Example

This Url connects to a SQL Server using the jTDS driver that works with Microsoft SQL 2008<pre>

Code Block
<resource-

...

def>   
  <url>jdbc:jtds:sqlserver://localhost:1433;DatabaseName=db;</url>

...


  <driver>net.sourceforge.jtds.jdbcx.JtdsDataSource</driver>

...


  <user>yourUser</user>

...


  <password>yourPassword</password>

...


</resource-def>

...

For SQL server, the database name can also be specified as part of the Url rather than using the DatabaseName optional parameter. For example if your database name is acswa and the SQL server is running on 59377:<pre>

Code Block
<url>jdbc:jtds:sqlserver://<sqlhost>:59377/acswa</url>

</pre>As of SQL 2000, Microsoft SQL allows installation of multiple [http://msdn.microsoft.com/en-us/library/aa176582%28v=sql.80%29.asp SQL named instances]. If your SQL server was installed this way you must use the instance parameter. For example if you database instance was named xyzzy:<pre>

Code Block
<url>jdbc:jtds:sqlserver://<sqlhost>:59377/acswa;instance=xyzzy</url>

...

AS400/DB2 Example

Here is an example that connects to an '''AS400/DB2 Open Universal driver'''. Notice that the url also specifics a date separator used in this database.<pre>

Code Block
<resource-def>

...


    <url>jdbc:as400://170.254.98.250:8888;date separator=-</

...

url>       
    <driver>com.ibm.as400.access.AS400JDBCDriver</driver>

...


    <user>yourUser</user>

...


    <password>yourPassword</password>

...


</resource-def>

</pre>