java: Namespace - JHU Distributed Computing Home Page ...

obtainablerabbiΔιαχείριση Δεδομένων

31 Ιαν 2013 (πριν από 4 χρόνια και 8 μήνες)

141 εμφανίσεις

Enterprise

Java

v040918

JBoss DataSource Setup

1

Setting up DataSources

in

JBoss

References:


JBoss Wiki


http://www.jboss.org/wiki/Wiki.jsp?page=ConfigDataSources


“Getting Started with JBoss, J2EE applications on the JBoss 3.2.x Server”
, Luke Taylor and The
JBoss Group. http://www.jboss.org/modules/html/docs/jbossj2ee.pdf


Enterprise

Java

v040918

JBoss DataSource Setup

2

JBoss DataSources


Implemented using Java Connector Architecture (JCA)


Either directly supported by vendor or using JDBC wrapper


Defined by a deployment descriptor ending in

ds.xml in
${JBOSS_SERVER}/deploy/


Vendor driver archive(s) placed in
${JBOSS_SERVER}/lib



Enterprise

Java

v040918

JBoss DataSource Setup

3

Database Sample Files Available


${JBOSS_HOME}/docs/examples/jca

asapxcess
-
jb3.2
-
ds.xml informix
-
ds.xml mysql
-
ds.xml

cicsr9s
-
service.xml informix
-
xa
-
ds.xml oracle
-
ds.xml

db2
-
ds.xml jdatastore
-
ds.xml oracle
-
xa
-
ds.xml

db2
-
xa
-
ds.xml jms
-
ds.xml postgres
-
ds.xml

facets
-
ds.xml jsql
-
ds.xml progress
-
ds.xml

fastobjects
-
jboss32
-
ds.xml lido
-
versant
-
service.xml sapdb
-
ds.xml

firebird
-
ds.xml mimer
-
ds.xml sapr3
-
ds.xml

generic
-
ds.xml mimer
-
xa
-
ds.xml solid
-
ds.xml

hajndi
-
jms
-
ds.xml msaccess
-
ds.xml sybase
-
ds.xml

hsqldb
-
ds.xml mssql
-
ds.xml

hsqldb
-
encrypted
-
ds.xml mssql
-
xa
-
ds.xml

Enterprise

Java

v040918

JBoss DataSource Setup

4

Basics


ex. xxx
-
ds.xml


<datasources>



<???
-
tx
-
datasource>


...



</???
-
tx
-
datasource>




<mbean …



</mbean>


</datasources>

Enterprise

Java

v040918

JBoss DataSource Setup

5

Types of DataSources


no
-
tx
-
datasource


does not take part in JTA transactions using a java.sql.Driver


rare for databases


local
-
tx
-
datasource


does not support two phase commit using a java.sql.Driver


xa
-
tx
-
datasource


does support two phase commit using a javax.sql.XADataSource

Enterprise

Java

v040918

JBoss DataSource Setup

6

Common java.sql.Driver Properties


connection
-
url


URL to database


ex. jdbc:hsqldb:hsql://localhost:9001


driver
-
class


vendor specific JDBC Driver in classpath


ex. org.hsqldb.jdbcDriver





Enterprise

Java

v040918

JBoss DataSource Setup

7

Common javax.sql.DataSource Properties


user
-
name


not used when security
-
domain specified


password


not used when security
-
domain specified


new
-
connection
-
sql



a test SQL statement which gets executed when connection taken from the
pool to determine if connection still valid


ex. select * from small
-
table


track
-
statements


watches for unclosed Statements and Result sets


<track
-
statements>nowarn</trackstatements> closes resources without
issuing warnings





Enterprise

Java

v040918

JBoss DataSource Setup

8

Common javax.sql.XADataSource Properties


xa
-
datasource
-
class


The vendor
-
specific class implementing XADataSource


xa
-
datasource
-
property


properties to configure XADataSource


these vary per driver


javap

classpath <driver archive> Driver


follow JavaBean semantics


ex.


<xa
-
datasource
-
property name="IfxWAITTIME">10</xa
-
datasource
-
property>


driver.setIfxWAITTIME(String)

Enterprise

Java

v040918

JBoss DataSource Setup

9

Example local
-
tx and xa DataSources

<datasources>


<local
-
tx
-
datasource>


<jndi
-
name>coredev/jdbc/pointbase/DS</jndi
-
name>


<connection
-
url>jdbc:pointbase:server://localhost:9092/coredev</connection
-
url>


<driver
-
class>com.pointbase.jdbc.jdbcUniversalDriver</driver
-
class>


<user
-
name>pbpublic</user
-
name>


<password>pbpublic</password>


</local
-
tx
-
datasource>


<xa
-
datasource>


<jndi
-
name>coredev/jdbc/pointbase/XaDS</jndi
-
name>


<xa
-
datasource
-
class>com.pointbase.xa.xaDataSource</xa
-
datasource
-
class>


<xa
-
datasource
-
property name="DatabaseName">


jdbc:pointbase:server://localhost:9092/coredev


</xa
-
datasource
-
property>


<xa
-
datasource
-
property name=“User">pbpublic</xa
-
datasource
-
property>


<xa
-
datasource
-
property name=“Password">pbpublic</xa
-
datasource
-
property>


</xa
-
datasource>

</datasources>

Enterprise

Java

v040918

JBoss DataSource Setup

10

Deploying local
-
tx and xa DataSources


[WrapperDataSourceService] Bound connection factory for resource
adapter for ConnectionManager
'jboss.jca:name=coredev/jdbc/pointbase/DS,service=

DataSourceBinding to JNDI name 'java:coredev/jdbc/pointbase/DS'


INFO [WrapperDataSourceService] Bound connection factory for
resource adapter for ConnectionManager
'jboss.jca:name=coredev/jdbc/pointbase/XaDS,service=

DataSourceBinding to JNDI name 'java:coredev/jdbc/pointbase/XaDS‘


java: Namespace


+
-

coredev (class: org.jnp.interfaces.NamingContext)


| +
-

jdbc (class: org.jnp.interfaces.NamingContext)


| | +
-

pointbase (class: org.jnp.interfaces.NamingContext)


| | | +
-

XaDS (class: javax.sql.DataSource)


| | | +
-

DS (class: javax.sql.DataSource)