At 09:23 AM 8/23/00 -0700, you wrote:
>What do I need to add to Jboss to do CMP with Jboss and Oracle?

Lee Turner sent in this tidbit, but I haven't added it to jBoss.org yet.

Adding a Data Source to jBoss 2

This section will detail how to add a data source to the jBoss 2 
server.  Version 2 of the jBoss server supports multiple data sources 
within the one server (unlike version 1).  The whole management of these 
data sources (along with the rest of the server) is done through the Java 
Management Extension (JMX) and as a result, the JMX documentation also 
applies to jBoss version 2.

The server including the data sources is created using a JMX MLet, which 
loads the configuration from the /conf/jboss.conf file.  The MLet sections 
that you need are the ones that use 'org.jboss.jdbc.DataSourceImpl' in the 
CODE tag.  The following are taken from the /conf/jboss.conf file which are 
installed with the server.


<MLET CODE = "org.jboss.jdbc.DataSourceImpl" ARCHIVE="jboss.jar,idb.jar" 
CODEBASE="../lib/ext/">
         <ARG TYPE="java.lang.String" 
VALUE="jdbc:idb:../conf/instantdb.properties">
         <ARG TYPE="java.lang.String" VALUE="InstantDB">
         <ARG TYPE="java.lang.String" VALUE="jdbc.idbDriver">
         <ARG TYPE="java.lang.String" VALUE="">
         <ARG TYPE="java.lang.String" VALUE="">
</MLET>

<MLET CODE = "org.jboss.jdbc.DataSourceImpl" ARCHIVE="jboss.jar,hsql.jar" 
CODEBASE="../lib/ext/">
         <ARG TYPE="java.lang.String" 
VALUE="jdbc:HypersonicSQL:hsql://localhost">
         <ARG TYPE="java.lang.String" VALUE="Hypersonic">
         <ARG TYPE="java.lang.String" VALUE="org.hsql.jdbcDriver">
         <ARG TYPE="java.lang.String" VALUE="sa">
         <ARG TYPE="java.lang.String" VALUE="">
</MLET>


It is these sections that replace the information in the system.properties 
file from jBoss 1.  Each tag in the MLet will be described below:

CODEThis tells jBoss what the MLet section is.  In the case of a data 
source, it uses the org.jboss.jdbc.DataSourceImpl class.
ARCHIVEThis tells the server where to look for drivers for the data 
source.  Jboss.jar needs to be in every data source, but the second jar is 
dependent on the data source you are adding.   The archives need to be in 
the classpath.
CODEBASEThis tells the server where to look for the archives in the 
previous tag.

The arguments (ARG) provide the JDBC specific information to connect to 
your data source.  The top one is the database URL, the second one is the 
JNDI name for the data source (you can choose this  no spaces), the third 
one is the JDBC driver class name and the forth and fifth are the username 
and password to connect to your data source.

Add the relevant information relating to your data source to the 
/conf/jboss.conf file and save it.  The next stage is to tell the jBoss to 
load the JDBC drivers.  To do this you must place the driver archive in the 
jBoss classpath.  In jBoss 2 this is really easy.  All you have to do is 
put the archive in the /lib/ext directory as all the jar files in this 
directory are automatically added to the classpath for you (cool or what).

The way you tell jBoss 2 to load the JDBC driver is to add the driver class 
to the /conf/jboss.properties file.  The line in the file that tells the 
server what drivers to load for the above data sources is as follows:

jdbc.drivers=org.hsql.jdbcDriver,jdbc.idbDriver

That's all the information the server needs to create and load a data 
source for your beans to use.  The jaws.xml file is used to tell your beans 
which data source to use.

Example  Adding an Oracle Data Source
1.      Downloaded the Oracle JDBC (thin) drivers from the Oracle web 
site.  This is usually in zip format, so I renamed the extension to '.jar' 
so jBoss can automatically add it to the classpath.
2.      Copied the archive to the /lib/ext directory so it is added to the 
jBoss classpath
3.      Added the driver name to the line to the /conf/jboss.properties file:
jdbc.drivers=org.hsql.jdbcDriver,jdbc.idbDriver,oracle.jdbc.driver.OracleDriver

4.      Added the JDBC connection information to the /conf/jboss.conf file:

<MLET CODE = "org.jboss.jdbc.DataSourceImpl" 
ARCHIVE="jboss.jar,classes102.jar" CODEBASE="../lib/ext/">
    <ARG TYPE="java.lang.String" 
VALUE="jdbc:oracle:thin:@192.9.200.80:1521:orcl">
    <ARG TYPE="java.lang.String" VALUE="Oracle">
    <ARG TYPE="java.lang.String" VALUE="oracle.jdbc.driver.OracleDriver">
    <ARG TYPE="java.lang.String" VALUE="scott">
    <ARG TYPE="java.lang.String" VALUE="tiger">
</MLET>

Turner's original was in MS Word format, and I still need to clean it up 
and post it in HTML format. Please let me know if this works for you, 
including even minor changes you'd make. I can't test this myself because I 
don't have Oracle.

-- Ken Jenks, http://abiblion.com/

    Tools for reading.



--
--------------------------------------------------------------
To subscribe:        [EMAIL PROTECTED]
To unsubscribe:      [EMAIL PROTECTED]
Problems?:           [EMAIL PROTECTED]

Reply via email to