Using H2 as a database in Glassfish v3 as a connection pool

902 views
Skip to first unread message

Albert Willemsen

unread,
Oct 26, 2009, 12:00:45 AM10/26/09
to H2 Database
I'm looking for a way to use H2 as a database driver in Glassfish v3
connection pool. But I can't find any good tutorials or a way to
accompish this.

Neunerball

unread,
Oct 26, 2009, 3:42:23 PM10/26/09
to H2 Database
Maybe this can help:

http://docs.sun.com/app/docs/doc/820-4496/fvyam?a=view


On Oct 26, 12:00 am, Albert Willemsen <albert.m.willem...@gmail.com>
wrote:

JavaGuy

unread,
Oct 27, 2009, 2:03:37 AM10/27/09
to H2 Database
Try this in your persistence.xml:

<?xml version="1.0" encoding="UTF-8"?>
<persistence version="1.0" xmlns="http://java.sun.com/xml/ns/
persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/persistence
http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd">
<persistence-unit name="testDBWebPU" transaction-type="JTA">
<jta-data-source>jdbc/h2testDB</jta-data-source>
<properties>
<property name="toplink.target-database"
value="oracle.toplink.essentials.platform.database.H2Platform"/>
</properties>
</persistence-unit>
</persistence>



And this in your sun-resources.xml:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE resources PUBLIC "-//Sun Microsystems, Inc.//DTD Application
Server 9.0 Resource Definitions //EN" "http://www.sun.com/software/
appserver/dtds/sun-resources_1_3.dtd">
<resources>
<jdbc-resource enabled="true" jndi-name="jdbc/h2testDB" object-
type="user" pool-
name="jdbc_h2_tcp_localhost_Java_DBs_testDB_testDB_adminPool"/>
<jdbc-connection-pool allow-non-component-callers="false" associate-
with-thread="false" connection-creation-retry-attempts="0" connection-
creation-retry-interval-in-seconds="10" connection-leak-
reclaim="false" connection-leak-timeout-in-seconds="0" connection-
validation-method="auto-commit" datasource-
classname="org.h2.jdbcx.JdbcDataSource" fail-all-connections="false"
idle-timeout-in-seconds="300" is-connection-validation-
required="false" is-isolation-level-guaranteed="true" lazy-connection-
association="false" lazy-connection-enlistment="false" match-
connections="false" max-connection-usage-count="0" max-pool-size="32"
max-wait-time-in-millis="60000"
name="jdbc_h2_tcp_localhost_Java_DBs_testDB_testDB_adminPool" non-
transactional-connections="false" pool-resize-quantity="2" res-
type="javax.sql.DataSource" statement-timeout-in-seconds="-1" steady-
pool-size="8" validate-atmost-once-period-in-seconds="0" wrap-jdbc-
objects="false">
<property name="User" value="aUsername"/>
<property name="Password" value="aPassword"/>
<property name="URL" value="jdbc:h2:tcp://localhost//Java/DBs/
testDB/testDB"/>
<property name="driverClass" value="org.h2.Driver"/>
</jdbc-connection-pool>
</resources>

Thomas Mueller

unread,
Oct 28, 2009, 2:10:26 PM10/28/09
to h2-da...@googlegroups.com
Hi,

I don't really know Glassfish. Currently this is the only
documentation included in H2:

http://www.h2database.com/html/tutorial.html#using_toplink

Please tell me what I should add to this documentation (links, examples,...)

Regards,
Thomas

Reply all
Reply to author
Forward
0 new messages