![]() |
![]() |
||||
This file provides a JNDI resource representing a FireBird datasource, to allow your application to use DBCP connection pooling.
You will need to replace YOUR_USERNAME, YOUR_PASSWORD, YOUR_DATABASE_NAME, and if necessary, the server name.
Save this file as <webapps>/<your application folder (eg: ROOT)>/META-INF/context.xml
Note that most applications do not have a META-INF folder by default. Create it next to the WEB-INF folder, so that your application contains both a WEB-INF and a META-INF folder.
<?xml version="1.0" encoding="UTF-8"?> <Context> <Resource name="jdbc/mydatabase" auth="Container" type="javax.sql.DataSource" username="YOUR_USERNAME" password="YOUR_PASSWORD" driverClassName="org.firebirdsql.jdbc.FBDriver" url="jdbc:firebirdsql://firebird.metawerx.net:3050/d:/firebird/data/YOUR_DATABASE_NAME.FDB" validationQuery="select 1" maxActive="10" maxIdle="2"/> </Context>
This datasource can be accessed in your java code with the following line:
// Get DataSource Context ctx = new InitialContext(); DataSource ds = (DataSource)ctx.lookup("java:comp/env/jdbc/mydatabase"); // Get Connection and Statement Connection c = ds.getConnection(); Statement s = c.createStatement();