[jboss-cvs] jboss-docs/adminguide/docbook/en/modules ...

Sam Griffith sam.griffith at jboss.com
Mon Mar 26 01:27:36 EDT 2007


  User: sgriffith
  Date: 07/03/26 01:27:36

  Modified:    adminguide/docbook/en/modules  appendix-alternative_DBs.xml
  Log:
  I added more about other db's. PostgreSQL in this one. Will paste in other text for other ones in another checkeckin.
  
  Revision  Changes    Path
  1.5       +469 -308  jboss-docs/adminguide/docbook/en/modules/appendix-alternative_DBs.xml
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: appendix-alternative_DBs.xml
  ===================================================================
  RCS file: /cvsroot/jboss/jboss-docs/adminguide/docbook/en/modules/appendix-alternative_DBs.xml,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -b -r1.4 -r1.5
  --- appendix-alternative_DBs.xml	26 Feb 2007 05:24:39 -0000	1.4
  +++ appendix-alternative_DBs.xml	26 Mar 2007 05:27:36 -0000	1.5
  @@ -3,10 +3,11 @@
   	<section>
   		<title>How to Us Alternative Databases</title>
   		<para>
  -			JBoss utilizes the Hypersonic database as it's default database. While this is good for development and prototyping, for production odds are that you or your company will require another database to be used for production. This appendix covers how to configure JBoss to use an alternatvie database. For our sample, we've choosen MySQL 5. It's free and readily available for most platforms in use today. 
  +			JBoss utilizes the Hypersonic database as it's default database. While this is good for development and prototyping, for production odds are that you or your company will require another database to be used for production. This appendix covers how to configure JBoss to use an alternative database. For our sample, we've chosen MySQL 5. It's free and readily available for most platforms in use today. 
   		</para>
   	</section>
  -	
  +	<section id="mysql">
  +		<title>Using MySQL as the Alternative DB</title>
   	<section>
   		<title>
   			Setting up MySQL
  @@ -15,61 +16,61 @@
   			MySQL is available for free from <literal>http://dev.mysql.com/downloads/</literal> for most major OS's. For this setup sample, we've downloaded the latest stable MySQL 5 version which happens to be MySQL 5.0.27. Follow the instructions for installing MySQL on your platform. 
   		</para>
   		<para>
  -			MySQL is interacted with and administered by uinsg the <literal>mysql</literal> command. On Mac OS X it is found in <literal>/usr/local/mysql/bin/mysql</literal>. To work with the <literal>mysql</literal> client you will most likely want to do it as a root user. To do so, use the<literal>-u</literal> or <literal>-user</literal> option. This allows you to specify the user name used when connecting to the database.
  +				MySQL is interacted with and administered by using the <literal>mysql</literal> command. On Mac OS X it is found in <literal>/usr/local/mysql/bin/mysql</literal>. To work with the <literal>mysql</literal> client you will most likely want to do it as a root user. To do so, use the<literal>-u</literal> or <literal>-user</literal> option. This allows you to specify the user name used when connecting to the database.
   			<programlisting>
  -$ mysql -u root
  -Welcome to the MySQL monitor.  Commands end with ; or \g.
  -Your MySQL connection id is 4 to server version: 5.0.27-standard
  +	$ mysql -u root
  +	Welcome to the MySQL monitor.  Commands end with ; or \g.
  +	Your MySQL connection id is 4 to server version: 5.0.27-standard
   
  -Type 'help;' or '\h' for help. Type '\c' to clear the buffer.
  +	Type 'help;' or '\h' for help. Type '\c' to clear the buffer.
   
  -mysql>
  +	mysql>
   			</programlisting>
   		</para>
   		<para>
   			After you've logged into MySQL you'll need to create a database with the name <literal>jboss</literal>. To do so, use the <literal>create database</literal> command like so:
   			<programlisting>
  -mysql> create database jboss;
  -Query OK, 1 row affected (0.01 sec)
  +	mysql> create database jboss;
  +	Query OK, 1 row affected (0.01 sec)
   			</programlisting>
   		</para>
   		<para>
   			Now that you've created a database we need to create a user for it so that we don't have to be root to access it. To do so, use the <literal>grant</literal> command like so:
   			<programlisting>
  -mysql> grant all privileges on jboss.* to sam at localhost identified by 'password';
  -Query OK, 0 rows affected (0.00 sec)
  +	mysql> grant all privileges on jboss.* to sam at localhost identified by 'password';
  +	Query OK, 0 rows affected (0.00 sec)
   			</programlisting>
   			With that grant command we created a user <literal>sam</literal> with a password <literal>password</literal>. User <literal>sam</literal> has access to everything in the <literal>jboss</literal> database.
   		</para>
   		<para>
   			We can look at the MySQL user table to see that <literal>sam</literal> has been added.
   			<programlisting>
  -mysql> select user, host, password from mysql.user;
  -+------+-------------------+-------------------------------------------+
  -| user | host              | password                                  |
  -+------+-------------------+-------------------------------------------+
  -| root | localhost         |                                           | 
  -| root | sam-griffiths.sme |                                           | 
  -|      | sam-griffiths.sme |                                           | 
  -|      | localhost         |                                           | 
  -| sam  | localhost         | *2470C0C06DEE42FD1618BB99005ADCA2EC9D1E19 | 
  -+------+-------------------+-------------------------------------------+
  -5 rows in set (0.01 sec)
  +	mysql> select user, host, password from mysql.user;
  +	+------+-------------------+-------------------------------------------+
  +	| user | host              | password                                  |
  +	+------+-------------------+-------------------------------------------+
  +	| root | localhost         |                                           | 
  +	| root | sam-griffiths.sme |                                           | 
  +	|      | sam-griffiths.sme |                                           | 
  +	|      | localhost         |                                           | 
  +	| sam  | localhost         | *2470C0C06DEE42FD1618BB99005ADCA2EC9D1E19 | 
  +	+------+-------------------+-------------------------------------------+
  +	5 rows in set (0.01 sec)
   			</programlisting>
   			We can now login to the database as <literal>sam</literal> instead of <literal>root</literal>. Let's see that work. Make sure if your still logged into the MySQL client, that you exit by typing in <literal>exit</literal> at the MySQL prompt like so:
   			<programlisting>
  -mysql> exit
  -Bye
  +	mysql> exit
  +	Bye
   			</programlisting>
   			Now you can login as the new user you created (in our case <literal>sam</literal>), like so:
   			<programlisting>
  -$ mysql -u sam --password=password
  -Welcome to the MySQL monitor.  Commands end with ; or \g.
  -Your MySQL connection id is 8 to server version: 5.0.27-standard
  +	$ mysql -u sam --password=password
  +	Welcome to the MySQL monitor.  Commands end with ; or \g.
  +	Your MySQL connection id is 8 to server version: 5.0.27-standard
   
  -Type 'help;' or '\h' for help. Type '\c' to clear the buffer.
  +	Type 'help;' or '\h' for help. Type '\c' to clear the buffer.
   
  -mysql>
  +	mysql>
   			</programlisting>
   			One thing to note is that we did not create our user with remote access permissions, so if you try to login from a remote machine to mysql with user <literal>sam</literal>, you will not be able too. See the MySQL documentation for further information on creating users with remote users.
   		</para>
  @@ -86,124 +87,124 @@
   		<para>
   			How can we tell if JBoss found that new MySQL driver? The quickest way is to look at our JMX console to see check which JDBC driver is loaded. Open your browser and go to: <literal>http://localhost:8080/jmx-console</literal>. Towards the top of the page you'll see the JMImplementation domain. Choose the <literal>name=Default,service=LoaderRepository</literal> MBean. On the screen for the LoaderRepository MBean you'll see a MBean operation for <literal>displayClassInfo()</literal>. In it's parameterValue text field put in <literal> com.mysql.jdbc.Driver</literal> and click the "Invoke" button. you should see something like this:
   			<programlisting>
  -com.mysql.jdbc.Driver Information
  -Not loaded in repository cache
  +	com.mysql.jdbc.Driver Information
  +	Not loaded in repository cache
   
   
  -### Instance0 found in UCL: 
  +	### Instance0 found in UCL: 
   	org.jboss.mx.loading.UnifiedClassLoader3 at 592141{ url=null ,addedOrder=2}
   			</programlisting>
   			While we haven't used the instance yet which would have caused the class to be loaded into the repository cache, we do have an instance, so JBoss knows about the driver and can see it. If we had used the class already we'd get much more information and it would look like this:
   			<programlisting>
  -com.mysql.jdbc.Driver Information
  -Repository cache version:
  -com.mysql.jdbc.Driver(634bac).ClassLoader=
  -org.jboss.mx.loading.UnifiedClassLoader3 at 3fa2d5{ url=null ,addedOrder=2}
  -..org.jboss.mx.loading.UnifiedClassLoader3 at 3fa2d5{ url=null ,addedOrder=2}
  -....file:/Users/sgriffith/jboss-4.2.0.CR1/server/default/lib/.DS_Store
  -....file:/Users/sgriffith/jboss-4.2.0.CR1/server/default/lib/activation.jar
  -....file:/Users/sgriffith/jboss-4.2.0.CR1/server/default/lib/antlr.jar
  -....file:/Users/sgriffith/jboss-4.2.0.CR1/server/default/lib/autonumber-plugin.jar
  -....file:/Users/sgriffith/jboss-4.2.0.CR1/server/default/lib/bcel.jar
  -....file:/Users/sgriffith/jboss-4.2.0.CR1/server/default/lib/bindingservice-plugin.jar
  -....file:/Users/sgriffith/jboss-4.2.0.CR1/server/default/lib/bsf.jar
  -....file:/Users/sgriffith/jboss-4.2.0.CR1/server/default/lib/bsh-deployer.jar
  -....file:/Users/sgriffith/jboss-4.2.0.CR1/server/default/lib/bsh.jar
  -....file:/Users/sgriffith/jboss-4.2.0.CR1/server/default/lib/cglib.jar
  -....file:/Users/sgriffith/jboss-4.2.0.CR1/server/default/lib/commons-codec.jar
  -....file:/Users/sgriffith/jboss-4.2.0.CR1/server/default/lib/commons-collections.jar
  -....file:/Users/sgriffith/jboss-4.2.0.CR1/server/default/lib/commons-httpclient.jar
  -....file:/Users/sgriffith/jboss-4.2.0.CR1/server/default/lib/commons-logging.jar
  -....file:/Users/sgriffith/jboss-4.2.0.CR1/server/default/lib/dom4j.jar
  -....file:/Users/sgriffith/jboss-4.2.0.CR1/server/default/lib/hibernate3.jar
  -....file:/Users/sgriffith/jboss-4.2.0.CR1/server/default/lib/hsqldb-plugin.jar
  -....file:/Users/sgriffith/jboss-4.2.0.CR1/server/default/lib/hsqldb.jar
  -....file:/Users/sgriffith/jboss-4.2.0.CR1/server/default/lib/javassist.jar
  -....file:/Users/sgriffith/jboss-4.2.0.CR1/server/default/lib/javax.el.jar
  -....file:/Users/sgriffith/jboss-4.2.0.CR1/server/default/lib/javax.servlet.jar
  -....file:/Users/sgriffith/jboss-4.2.0.CR1/server/default/lib/javax.servlet.jsp.jar
  -....file:/Users/sgriffith/jboss-4.2.0.CR1/server/default/lib/jaxen.jar
  -....file:/Users/sgriffith/jboss-4.2.0.CR1/server/default/lib/jboss-backport-concurrent.jar
  -....file:/Users/sgriffith/jboss-4.2.0.CR1/server/default/lib/jboss-common-jdbc-wrapper.jar
  -....file:/Users/sgriffith/jboss-4.2.0.CR1/server/default/lib/jboss-hibernate.jar
  -....file:/Users/sgriffith/jboss-4.2.0.CR1/server/default/lib/jboss-j2ee.jar
  -....file:/Users/sgriffith/jboss-4.2.0.CR1/server/default/lib/jboss-jaxrpc.jar
  -....file:/Users/sgriffith/jboss-4.2.0.CR1/server/default/lib/jboss-jca.jar
  -....file:/Users/sgriffith/jboss-4.2.0.CR1/server/default/lib/jboss-jsr77.jar
  -....file:/Users/sgriffith/jboss-4.2.0.CR1/server/default/lib/jboss-jsr88.jar
  -....file:/Users/sgriffith/jboss-4.2.0.CR1/server/default/lib/jboss-management.jar
  -....file:/Users/sgriffith/jboss-4.2.0.CR1/server/default/lib/jboss-monitoring.jar
  -....file:/Users/sgriffith/jboss-4.2.0.CR1/server/default/lib/jboss-remoting-int.jar
  -....file:/Users/sgriffith/jboss-4.2.0.CR1/server/default/lib/jboss-remoting.jar
  -....file:/Users/sgriffith/jboss-4.2.0.CR1/server/default/lib/jboss-saaj.jar
  -....file:/Users/sgriffith/jboss-4.2.0.CR1/server/default/lib/jboss-serialization.jar
  -....file:/Users/sgriffith/jboss-4.2.0.CR1/server/default/lib/jboss-srp.jar
  -....file:/Users/sgriffith/jboss-4.2.0.CR1/server/default/lib/jboss-transaction.jar
  -....file:/Users/sgriffith/jboss-4.2.0.CR1/server/default/lib/jboss.jar
  -....file:/Users/sgriffith/jboss-4.2.0.CR1/server/default/lib/jbossjta-integration.jar
  -....file:/Users/sgriffith/jboss-4.2.0.CR1/server/default/lib/jbossjta.jar
  -....file:/Users/sgriffith/jboss-4.2.0.CR1/server/default/lib/jbossmq.jar
  -....file:/Users/sgriffith/jboss-4.2.0.CR1/server/default/lib/jbossretro-rt.jar
  -....file:/Users/sgriffith/jboss-4.2.0.CR1/server/default/lib/jbosssx.jar
  -....file:/Users/sgriffith/jboss-4.2.0.CR1/server/default/lib/jbossts-common.jar
  -....file:/Users/sgriffith/jboss-4.2.0.CR1/server/default/lib/jmx-adaptor-plugin.jar
  -....file:/Users/sgriffith/jboss-4.2.0.CR1/server/default/lib/jnpserver.jar
  -....file:/Users/sgriffith/jboss-4.2.0.CR1/server/default/lib/joesnmp.jar
  -....file:/Users/sgriffith/jboss-4.2.0.CR1/server/default/lib/jpl-pattern.jar
  -....file:/Users/sgriffith/jboss-4.2.0.CR1/server/default/lib/jpl-util.jar
  -....file:/Users/sgriffith/jboss-4.2.0.CR1/server/default/lib/log4j-snmp-appender.jar
  -....file:/Users/sgriffith/jboss-4.2.0.CR1/server/default/lib/log4j.jar
  -....file:/Users/sgriffith/jboss-4.2.0.CR1/server/default/lib/mail-plugin.jar
  -....file:/Users/sgriffith/jboss-4.2.0.CR1/server/default/lib/mail.jar
  -....file:/Users/sgriffith/jboss-4.2.0.CR1/server/default/lib/mysql-connector-java-5.0.4-bin.jar
  -....file:/Users/sgriffith/jboss-4.2.0.CR1/server/default/lib/properties-plugin.jar
  -....file:/Users/sgriffith/jboss-4.2.0.CR1/server/default/lib/scheduler-plugin-example.jar
  -....file:/Users/sgriffith/jboss-4.2.0.CR1/server/default/lib/scheduler-plugin.jar
  -....file:/Users/sgriffith/jboss-4.2.0.CR1/server/default/lib/wsdl4j.jar
  -....file:/Users/sgriffith/jboss-4.2.0.CR1/server/default/lib/xmlentitymgr.jar
  -..org.jboss.system.server.NoAnnotationURLClassLoader at 7471e0
  -..sun.misc.Launcher$AppClassLoader at e39a3e
  -....file:/Users/sgriffith/jboss-4.2.0.CR1/bin/run.jar
  -....file:/lib/tools.jar
  -....file:/System/Library/Frameworks/JavaVM.framework/
  -Versions/1.5.0/Classes/.compatibility/14compatibility.jar
  -..sun.misc.Launcher$ExtClassLoader at 92e78c
  -....file:/Library/Java/Extensions/.DS_Store
  -....file:/Library/Java/Extensions/junit-4.1.jar
  -....file:/usr/local/lib/libsvnjavahl-1.0.0.0.dylib
  -....file:/Library/Java/Extensions/OpenBaseJDBC.jar
  -....file:/System/Library/Java/Extensions/CoreAudio.jar
  -....file:/System/Library/Java/Extensions/dns_sd.jar
  -....file:/System/Library/Java/Extensions/j3daudio.jar
  -....file:/System/Library/Java/Extensions/j3dcore.jar
  -....file:/System/Library/Java/Extensions/j3dutils.jar
  -....file:/System/Library/Java/Extensions/jai_codec.jar
  -....file:/System/Library/Java/Extensions/jai_core.jar
  -....file:/System/Library/Java/Extensions/libJ3D.jnilib
  -....file:/System/Library/Java/Extensions/libJ3DAudio.jnilib
  -....file:/System/Library/Java/Extensions/libJ3DUtils.jnilib
  -....file:/System/Library/Java/Extensions/libmlib_jai.jnilib
  -....file:/System/Library/Java/Extensions/mlibwrapper_jai.jar
  -....file:/System/Library/Java/Extensions/MRJToolkit.jar
  -....file:/System/Library/Java/Extensions/QTJava.zip
  -....file:/System/Library/Java/Extensions/QTJSupport.jar
  -....file:/System/Library/Java/Extensions/vecmath.jar
  -....file:/System/Library/Frameworks/JavaVM.framework/Versions/1.5.0/Home/lib/ext/
  -apple_provider.jar
  -....file:/System/Library/Frameworks/JavaVM.framework/Versions/1.5.0/Home/lib/ext/dnsns.jar
  -....file:/System/Library/Frameworks/JavaVM.framework/Versions/1.5.0/Home/lib/ext/localedata.jar
  -....file:/System/Library/Frameworks/JavaVM.framework/Versions/1.5.0/Home/lib/ext/
  -sunjce_provider.jar
  -....file:/System/Library/Frameworks/JavaVM.framework/Versions/1.5.0/Home/lib/ext/sunpkcs11.jar
  -++++CodeSource: (file:/Users/sgriffith/jboss-4.2.0.CR1/server/default/lib/
  -mysql-connector-java-5.0.4-bin.jar )
  -Implemented Interfaces:
  -++interface java.sql.Driver(e86394)
  -++++ClassLoader: null
  -++++Null CodeSource
  +	com.mysql.jdbc.Driver Information
  +	Repository cache version:
  +	com.mysql.jdbc.Driver(634bac).ClassLoader=
  +	org.jboss.mx.loading.UnifiedClassLoader3 at 3fa2d5{ url=null ,addedOrder=2}
  +	..org.jboss.mx.loading.UnifiedClassLoader3 at 3fa2d5{ url=null ,addedOrder=2}
  +	....file:/Users/sgriffith/jboss-4.2.0.CR1/server/default/lib/.DS_Store
  +	....file:/Users/sgriffith/jboss-4.2.0.CR1/server/default/lib/activation.jar
  +	....file:/Users/sgriffith/jboss-4.2.0.CR1/server/default/lib/antlr.jar
  +	....file:/Users/sgriffith/jboss-4.2.0.CR1/server/default/lib/autonumber-plugin.jar
  +	....file:/Users/sgriffith/jboss-4.2.0.CR1/server/default/lib/bcel.jar
  +	....file:/Users/sgriffith/jboss-4.2.0.CR1/server/default/lib/bindingservice-plugin.jar
  +	....file:/Users/sgriffith/jboss-4.2.0.CR1/server/default/lib/bsf.jar
  +	....file:/Users/sgriffith/jboss-4.2.0.CR1/server/default/lib/bsh-deployer.jar
  +	....file:/Users/sgriffith/jboss-4.2.0.CR1/server/default/lib/bsh.jar
  +	....file:/Users/sgriffith/jboss-4.2.0.CR1/server/default/lib/cglib.jar
  +	....file:/Users/sgriffith/jboss-4.2.0.CR1/server/default/lib/commons-codec.jar
  +	....file:/Users/sgriffith/jboss-4.2.0.CR1/server/default/lib/commons-collections.jar
  +	....file:/Users/sgriffith/jboss-4.2.0.CR1/server/default/lib/commons-httpclient.jar
  +	....file:/Users/sgriffith/jboss-4.2.0.CR1/server/default/lib/commons-logging.jar
  +	....file:/Users/sgriffith/jboss-4.2.0.CR1/server/default/lib/dom4j.jar
  +	....file:/Users/sgriffith/jboss-4.2.0.CR1/server/default/lib/hibernate3.jar
  +	....file:/Users/sgriffith/jboss-4.2.0.CR1/server/default/lib/hsqldb-plugin.jar
  +	....file:/Users/sgriffith/jboss-4.2.0.CR1/server/default/lib/hsqldb.jar
  +	....file:/Users/sgriffith/jboss-4.2.0.CR1/server/default/lib/javassist.jar
  +	....file:/Users/sgriffith/jboss-4.2.0.CR1/server/default/lib/javax.el.jar
  +	....file:/Users/sgriffith/jboss-4.2.0.CR1/server/default/lib/javax.servlet.jar
  +	....file:/Users/sgriffith/jboss-4.2.0.CR1/server/default/lib/javax.servlet.jsp.jar
  +	....file:/Users/sgriffith/jboss-4.2.0.CR1/server/default/lib/jaxen.jar
  +	....file:/Users/sgriffith/jboss-4.2.0.CR1/server/default/lib/jboss-backport-concurrent.jar
  +	....file:/Users/sgriffith/jboss-4.2.0.CR1/server/default/lib/jboss-common-jdbc-wrapper.jar
  +	....file:/Users/sgriffith/jboss-4.2.0.CR1/server/default/lib/jboss-hibernate.jar
  +	....file:/Users/sgriffith/jboss-4.2.0.CR1/server/default/lib/jboss-j2ee.jar
  +	....file:/Users/sgriffith/jboss-4.2.0.CR1/server/default/lib/jboss-jaxrpc.jar
  +	....file:/Users/sgriffith/jboss-4.2.0.CR1/server/default/lib/jboss-jca.jar
  +	....file:/Users/sgriffith/jboss-4.2.0.CR1/server/default/lib/jboss-jsr77.jar
  +	....file:/Users/sgriffith/jboss-4.2.0.CR1/server/default/lib/jboss-jsr88.jar
  +	....file:/Users/sgriffith/jboss-4.2.0.CR1/server/default/lib/jboss-management.jar
  +	....file:/Users/sgriffith/jboss-4.2.0.CR1/server/default/lib/jboss-monitoring.jar
  +	....file:/Users/sgriffith/jboss-4.2.0.CR1/server/default/lib/jboss-remoting-int.jar
  +	....file:/Users/sgriffith/jboss-4.2.0.CR1/server/default/lib/jboss-remoting.jar
  +	....file:/Users/sgriffith/jboss-4.2.0.CR1/server/default/lib/jboss-saaj.jar
  +	....file:/Users/sgriffith/jboss-4.2.0.CR1/server/default/lib/jboss-serialization.jar
  +	....file:/Users/sgriffith/jboss-4.2.0.CR1/server/default/lib/jboss-srp.jar
  +	....file:/Users/sgriffith/jboss-4.2.0.CR1/server/default/lib/jboss-transaction.jar
  +	....file:/Users/sgriffith/jboss-4.2.0.CR1/server/default/lib/jboss.jar
  +	....file:/Users/sgriffith/jboss-4.2.0.CR1/server/default/lib/jbossjta-integration.jar
  +	....file:/Users/sgriffith/jboss-4.2.0.CR1/server/default/lib/jbossjta.jar
  +	....file:/Users/sgriffith/jboss-4.2.0.CR1/server/default/lib/jbossmq.jar
  +	....file:/Users/sgriffith/jboss-4.2.0.CR1/server/default/lib/jbossretro-rt.jar
  +	....file:/Users/sgriffith/jboss-4.2.0.CR1/server/default/lib/jbosssx.jar
  +	....file:/Users/sgriffith/jboss-4.2.0.CR1/server/default/lib/jbossts-common.jar
  +	....file:/Users/sgriffith/jboss-4.2.0.CR1/server/default/lib/jmx-adaptor-plugin.jar
  +	....file:/Users/sgriffith/jboss-4.2.0.CR1/server/default/lib/jnpserver.jar
  +	....file:/Users/sgriffith/jboss-4.2.0.CR1/server/default/lib/joesnmp.jar
  +	....file:/Users/sgriffith/jboss-4.2.0.CR1/server/default/lib/jpl-pattern.jar
  +	....file:/Users/sgriffith/jboss-4.2.0.CR1/server/default/lib/jpl-util.jar
  +	....file:/Users/sgriffith/jboss-4.2.0.CR1/server/default/lib/log4j-snmp-appender.jar
  +	....file:/Users/sgriffith/jboss-4.2.0.CR1/server/default/lib/log4j.jar
  +	....file:/Users/sgriffith/jboss-4.2.0.CR1/server/default/lib/mail-plugin.jar
  +	....file:/Users/sgriffith/jboss-4.2.0.CR1/server/default/lib/mail.jar
  +	....file:/Users/sgriffith/jboss-4.2.0.CR1/server/default/lib/mysql-connector-java-5.0.4-bin.jar
  +	....file:/Users/sgriffith/jboss-4.2.0.CR1/server/default/lib/properties-plugin.jar
  +	....file:/Users/sgriffith/jboss-4.2.0.CR1/server/default/lib/scheduler-plugin-example.jar
  +	....file:/Users/sgriffith/jboss-4.2.0.CR1/server/default/lib/scheduler-plugin.jar
  +	....file:/Users/sgriffith/jboss-4.2.0.CR1/server/default/lib/wsdl4j.jar
  +	....file:/Users/sgriffith/jboss-4.2.0.CR1/server/default/lib/xmlentitymgr.jar
  +	..org.jboss.system.server.NoAnnotationURLClassLoader at 7471e0
  +	..sun.misc.Launcher$AppClassLoader at e39a3e
  +	....file:/Users/sgriffith/jboss-4.2.0.CR1/bin/run.jar
  +	....file:/lib/tools.jar
  +	....file:/System/Library/Frameworks/JavaVM.framework/
  +	Versions/1.5.0/Classes/.compatibility/14compatibility.jar
  +	..sun.misc.Launcher$ExtClassLoader at 92e78c
  +	....file:/Library/Java/Extensions/.DS_Store
  +	....file:/Library/Java/Extensions/junit-4.1.jar
  +	....file:/usr/local/lib/libsvnjavahl-1.0.0.0.dylib
  +	....file:/Library/Java/Extensions/OpenBaseJDBC.jar
  +	....file:/System/Library/Java/Extensions/CoreAudio.jar
  +	....file:/System/Library/Java/Extensions/dns_sd.jar
  +	....file:/System/Library/Java/Extensions/j3daudio.jar
  +	....file:/System/Library/Java/Extensions/j3dcore.jar
  +	....file:/System/Library/Java/Extensions/j3dutils.jar
  +	....file:/System/Library/Java/Extensions/jai_codec.jar
  +	....file:/System/Library/Java/Extensions/jai_core.jar
  +	....file:/System/Library/Java/Extensions/libJ3D.jnilib
  +	....file:/System/Library/Java/Extensions/libJ3DAudio.jnilib
  +	....file:/System/Library/Java/Extensions/libJ3DUtils.jnilib
  +	....file:/System/Library/Java/Extensions/libmlib_jai.jnilib
  +	....file:/System/Library/Java/Extensions/mlibwrapper_jai.jar
  +	....file:/System/Library/Java/Extensions/MRJToolkit.jar
  +	....file:/System/Library/Java/Extensions/QTJava.zip
  +	....file:/System/Library/Java/Extensions/QTJSupport.jar
  +	....file:/System/Library/Java/Extensions/vecmath.jar
  +	....file:/System/Library/Frameworks/JavaVM.framework/Versions/1.5.0/Home/lib/ext/
  +	apple_provider.jar
  +	....file:/System/Library/Frameworks/JavaVM.framework/Versions/1.5.0/Home/lib/ext/dnsns.jar
  +	....file:/System/Library/Frameworks/JavaVM.framework/Versions/1.5.0/Home/lib/ext/localedata.jar
  +	....file:/System/Library/Frameworks/JavaVM.framework/Versions/1.5.0/Home/lib/ext/
  +	sunjce_provider.jar
  +	....file:/System/Library/Frameworks/JavaVM.framework/Versions/1.5.0/Home/lib/ext/sunpkcs11.jar
  +	++++CodeSource: (file:/Users/sgriffith/jboss-4.2.0.CR1/server/default/lib/
  +	mysql-connector-java-5.0.4-bin.jar )
  +	Implemented Interfaces:
  +	++interface java.sql.Driver(e86394)
  +	++++ClassLoader: null
  +	++++Null CodeSource
   
  -### Instance0 found in UCL: 
  -org.jboss.mx.loading.UnifiedClassLoader3 at 3fa2d5{ url=null ,addedOrder=2}
  +	### Instance0 found in UCL: 
  +	org.jboss.mx.loading.UnifiedClassLoader3 at 3fa2d5{ url=null ,addedOrder=2}
   			</programlisting>
   		</para>
   	</section>
  @@ -218,24 +219,23 @@
   		<para>
   			A MySQL datasource definition can be found in <literal>jboss-4.2.0.CR1/docs/examples/jca</literal>.  If you look in there you'll find a file called <literal>mysql-ds.xml</literal>. It looks like this:
   
  -![CDATA[
  -<datasources>
  +	![CDATA[
  +	<datasources>
     <local-tx-datasource>
       <jndi-name>MySqlDS</jndi-name>
       <connection-url>jdbc:mysql://mysql-hostname:3306/jbossdb</connection-url>
       <driver-class>com.mysql.jdbc.Driver</driver-class>
       <user-name>x</user-name>
       <password>y</password>
  -    <exception-sorter-class-name>
  -			org.jboss.resource.adapter.jdbc.vendor.MySQLExceptionSorter
  -		</exception-sorter-class-name>
  +	    <exception-sorter-class-name>org.jboss.resource.adapter.jdbc.vendor.MySQLExceptionSorter</exception-sorter-class-name>
       <!-- should only be used on drivers after 3.22.1 with "ping" support
       <valid-connection-checker-class-name>org.jboss.resource.adapter.jdbc.vendor.MySQLValidConnectionChecker</valid-connection-checker-class-name>
       -->
       <!-- sql to call when connection is created
       <new-connection-sql>some arbitrary sql</new-connection-sql>
         -->
  -    <!-- sql to call on an existing pooled connection when it is obtained from pool - MySQLValidConnectionChecker is preferred for newer drivers
  +	    <!-- sql to call on an existing pooled connection when it is obtained from pool - MySQLValidConnectionChecker is preferred for
  +	newer drivers
       <check-valid-connection-sql>some arbitrary sql</check-valid-connection-sql>
         -->
   
  @@ -244,15 +244,15 @@
          <type-mapping>mySQL</type-mapping>
       </metadata>
     </local-tx-datasource>
  -</datasources>
  -]]
  +	</datasources>
  +	]]
   
   		</para>
   		<para>
  -			We need to copy that file to the <literal>deploy</literal> directory for our server. (In our case "default"). Once we do that we need to change the <literal>connection-url</literal> to <literal>jdbc:mysql://localhost:3306/jboss</literal>. For the username put <literal>sam</literal> and for the password put <literal>password</literal>.
  +				We need to copy that file to the <literal>deploy</literal> directory for our server. (In our case "default"). Once we do that we need to change the <literal>connection-url</literal> to <literal>jdbc:postgresql://localhost:3306/jboss</literal>. For the username put <literal>sam</literal> and for the password put <literal>password</literal>.
   
  -![CDATA[
  -<datasources>
  +	![CDATA[
  +	<datasources>
     <local-tx-datasource>
       <jndi-name>MySqlDS</jndi-name>
       <connection-url>jdbc:mysql://localhost:3306/jboss</connection-url>
  @@ -277,14 +277,14 @@
          <type-mapping>mySQL</type-mapping>
       </metadata>
     </local-tx-datasource>
  -</datasources>
  -]]
  +	</datasources>
  +	]]
   
   		</para>
   			<para>When you save the file you should see the datasource be bound by JBoss in the console output like below. Each time you save the file the datasource will be bound and unbound, so you may see multiple entries like below.
   			<programlisting>
  -15:57:26,891 INFO  [WrapperDataSourceService] Bound ConnectionManager 
  -'jboss.jca:service=DataSourceBinding,name=MySqlDS' to JNDI name 'java:MySqlDS'
  +	15:57:26,891 INFO  [WrapperDataSourceService] Bound ConnectionManager 
  +	'jboss.jca:service=DataSourceBinding,name=MySqlDS' to JNDI name 'java:MySqlDS'
   			</programlisting>
   		</para>
   		<para>
  @@ -297,15 +297,15 @@
   		<para>
   			To configure your application to use MySQL, look for a *jbosscmp-jdbc.xml deployment descriptor. It is located in your servers <literal>conf</literal> directory. 
   
  -![CDATA[
  -<jbosscmp-jdbc>
  +	![CDATA[
  +	<jbosscmp-jdbc>
      <defaults>
         <datasource>java:/MySqlDS</datasource>
         <!-- optional since 4.0 <datasource-mapping>Hypersonic SQL</datasource-mapping> -->
   			<datasource-mapping>mySQL</datasource-mapping>
      </defaults>
  -</jbosscmp-jdbc>
  -]]
  +	</jbosscmp-jdbc>
  +	]]
   
   			Although the <literal>datasource-mapping</literal> is optional, it is nice to know the type of the datasource, as this ties directly back to the type-mapping of the data-source.
   		</para>
  @@ -490,5 +490,166 @@
   		Now we have JBoss using MySQL as it's default datasource and starting up with no errors.
   		</para>
   	</section>
  +	</section>
  +	<section id="postgresql">
  +		<title>Using PostgreSQL as the Alternative DB</title>
  +		<section id="setting-up-postgresql">
  +			<title>Setting up PostgreSQL</title>
  +			<para>
  +				PostgreSQL is available for free from <ulink url="http://www.postgresql.org/">http://www.postgresql.org/</ulink> in source and binary for Linux and Windows platforms and other sites for other platforms. Google will help you find the others if you need too. The installation instructions are covered in Chapter 14 of the PostgreSQL 8.2 docs, so follow those to finish setting up. For our sample we're using OS X so the following instructions talk about how to do it on OS X.
  +			</para>
  +			<para>
  +					Using Google we found this site: <ulink url="http://www.entropy.ch/software/macosx/postgresql/">http://www.entropy.ch/software/macosx/postgresql/</ulink> to get a prebuilt OS X version. This prebuilt version has some additional packages built in like the jbdc driver also. On that same site right where the download is, the installation instructions for OS X are also there. Once you have the download, you'll untar the <literal>.tar</literal> file by double-clicking it in the Finder. This will then give you a <literal>.pkg</literal> file you can then double-click to install. Follow the rest of the instructions on the www.entropy.ch site to add the <literal>PostgreSQL</literal> user to the OS, init and start <literal>PostgreSQL</literal> and finally create the <literal>test</literal> database. We won't use that test database but it is nice to have around for other uses.
  +			</para>
  +			<para>
  +				We now need to create our jboss database. Notice that we first <literal>su</literal> up to the user <literal>postgres</literal> that was created in the install instructions. We do this because that user owns all the commands we need to run. You can change that but that's not in the scope of our example. See a good UNIX reference for how to do that. After we've become the <literal>postgres</literal> user, we then use the <literal>createdb</literal> command to make our jboss database.
  +			</para>
  +			<programlisting>
  +sam-griffiths:~ sgriffith$ su postgres
  +Password:
  +sam-griffiths:/Users/sgriffith postgres$ createdb jboss 
  +CREATE DATABASE
  +sam-griffiths:/Users/sgriffith postgres$ 
  +			</programlisting>
  +			<para>
  +				So now the database is created. Now we need to go in and connect to it and add our jboss user.
  +				<programlisting>
  +sam-griffiths:/Users/sgriffith postgres$ psql jboss
  +Welcome to psql 8.2.3, the PostgreSQL interactive terminal.
  +
  +Type:  \copyright for distribution terms
  +       \h for help with SQL commands
  +       \? for help with psql commands
  +       \g or terminate with semicolon to execute query
  +       \q to quit
  +
  +jboss=#
  +				</programlisting>
  +			</para>
  +			<para>
  +				Now we'll add our jboss user as well.
  +				<programlisting>
  +jboss=# create user jboss encrypted password 'password' createrole createdb;
  +CREATE ROLE
  +jboss=# \du
  +                               List of roles
  + Role name | Superuser | Create role | Create DB | Connections | Member of 
  +-----------+-----------+-------------+-----------+-------------+-----------
  + jboss     | no        | yes         | yes       | no limit    | 
  + postgres  | yes       | yes         | yes       | no limit    | 
  +(2 rows)
  +				</programlisting>
  +			</para>
  +		</section>
  +		
  +		<section>
  +			<title>Adding the PostgreSQL JDBC Driver</title>
  +			<para>
  +				For the JBoss Application Server and our applications to use the PostgreSQL database, we also need to install the PostgreSQL JDBC drivers. They can be obtained from: <literal>http://jdbc.postgresql.org/</literal>. For our 8.2.3 version we need the JDBC3 driver <literal>8.2-504 JDBC 3</literal>. The download is just the JDBC driver <literal>postgresql-8.2-504.jdbc3.jar</literal> file to get PostgresSQL to work with and be used by JBoss. You'll need to copy that jar file to your JBoss servers <literal>lib</literal> directory. We copied it to our <literal>server/default/lib</literal> directory. This file will now be loaded when JBoss starts up. So if you have the JBoss server running, you'll need to shut down and restart before this jar is available for the App Server to use.
  +			</para>
  +			<para>
  +				How can we tell if JBoss found that new PostgresSQL driver? The quickest way is to look at our JMX console to see check which JDBC driver is loaded. Open your browser and go to: <literal>http://localhost:8080/jmx-console</literal>. Towards the top of the page you'll see the JMImplementation domain. Choose the  <literal>name=Default,service=LoaderRepository</literal> MBean. On the screen for the LoaderRepository MBean you'll see a MBean operation for <literal>displayClassInfo()</literal>. In it's parameterValue text field put in <literal>org.postgresql.Driver</literal> and click the "Invoke" button. You should see something like this:
  +				<programlisting>
  +org.postgresql.Driver Information
  +Not loaded in repository cache
  +
  +				</programlisting>
  +				While we haven't used the instance yet which would have caused the class to be loaded into the repository cache, we do have an instance, so JBoss knows about the driver and can see it. If we had used the class already we'd get much more information and it would look like this:
  +				<programlisting>
  +???? Show sample program running output ????
  +				</programlisting>
  +			</para>
  +		</section>
  +		
  +		<section>
  +			<title>Creating Datasource for PostgreSQL</title>
  +			<para>
  +						<para>
  +							JBoss allows us to create new data sources for our applications as well as providing one known as <literal>defaultDS</literal>. These datasource definitions can be found in the <literal>deploy</literal> directory of our server definition. The datasource definitions are deployable just like WAR and EAR files. The datasource files can be recognized by looking for the XML files (.xml) that end in <literal>*-ds.xml</literal>. The HyperSonic datasource file is named <literal>hsqldb-ds.xml</literal>. You can look at that file for an exmaple. The things to notice when you look at the HyperSonic datasource are that it's defined with the jndi-name of <literal>defaultDS</literal> it has the username and password included in it, and some other odds and ends.
  +						</para>
  +						<para>
  +							A PostgreSQL datasource definition can be found in <literal>jboss-4.2.0.CR1/docs/examples/jca</literal>.  If you look in there you'll find a file called <literal>postgres-ds.xml</literal>. It looks like this:
  +
  +				![CDATA[
  +<datasources>
  +  <local-tx-datasource>
  +    <jndi-name>PostgresDS</jndi-name>
  +    <connection-url>jdbc:postgresql://[servername]:[port]/[database name]</connection-url>
  +    <driver-class>org.postgresql.Driver</driver-class>
  +    <user-name>x</user-name>
  +    <password>y</password>
  +        <!-- sql to call when connection is created.  Can be anything, select 1 is valid for PostgreSQL
  +        <new-connection-sql>select 1</new-connection-sql>
  +        -->
  +
  +        <!-- sql to call on an existing pooled connection when it is obtained from pool.  Can be anything, select 1 is valid for PostgreSQL
  +        <check-valid-connection-sql>select 1</check-valid-connection-sql>
  +        -->
  +
  +      <!-- corresponding type-mapping in the standardjbosscmp-jdbc.xml (optional) -->
  +      <metadata>
  +         <type-mapping>PostgreSQL 7.2</type-mapping>
  +      </metadata>
  +  </local-tx-datasource>
  +
  +</datasources>
  +				]]
  +
  +						</para>
  +						<para>
  +							We need to copy that file to the <literal>deploy</literal> directory for our server. (In our case "default"). Once we do that we need to change the <literal>connection-url</literal> to <literal>jdbc:postgresql://localhost:3306/jboss</literal>. For the username put <literal>sam</literal> and for the password put <literal>password</literal>.
  +
  +				![CDATA[
  +<datasources>
  +  <local-tx-datasource>
  +    <jndi-name>PostgresDS</jndi-name>
  +    <connection-url>jdbc:postgresql://[servername]:[port]/[database name]</connection-url>
  +    <driver-class>org.postgresql.Driver</driver-class>
  +    <user-name>jboss</user-name>
  +    <password>password</password>
  +        <!-- sql to call when connection is created.  Can be anything, select 1 is valid for PostgreSQL
  +        <new-connection-sql>select 1</new-connection-sql>
  +        -->
  +
  +        <!-- sql to call on an existing pooled connection when it is obtained from pool.  Can be anything, select 1 is valid for PostgreSQL
  +        <check-valid-connection-sql>select 1</check-valid-connection-sql>
  +        -->
  +
  +      <!-- corresponding type-mapping in the standardjbosscmp-jdbc.xml (optional) -->
  +      <metadata>
  +         <type-mapping>PostgreSQL 7.2</type-mapping>
  +      </metadata>
  +  </local-tx-datasource>
  +
  +</datasources>
  +				]]
  +
  +						</para>
  +							<para>When you save the file you should see the datasource be bound by JBoss in the console output like below. Each time you save the file the datasource will be bound and unbound, so you may see multiple entries like below.
  +							<programlisting>
  +18:01:23,304 INFO  [ConnectionFactoryBindingService] Bound ConnectionManager 'jboss.jca:service=DataSourceBinding,name=PostgresDS' to JNDI name 'java:PostgresDS'
  +							</programlisting>
  +						</para>
  +						<para>
  +							This is how you configure a datasource for use in JBoss application server. Note that we did not take the HyperSonic datasource away as it is used by many JBoss services. If you are going to deploy to production, you will want to configure each service to use a specific datasource. Such as configuring JMS to use MySQL instead of the <literal>defaultDS</literal>. We'll see how to do that in another section.
  +						</para>				
  +			</para>
  +		</section>
  +		
  +		<section>
  +			<title>Linking the Datasource to your application</title>
  +			<para>
  +				
  +			</para>
  +		</section>
  +		
  +		<section>
  +			<title>Changing the DefaultDS for all of JBoss</title>
  +			<para>
  +				
  +			</para>
  +		</section>
  +		
  +	</section>
   	
   </appendix>
  \ No newline at end of file
  
  
  



More information about the jboss-cvs-commits mailing list