Home > Articles > Programming > Java

  • Print
  • + Share This
From the author of

Prerequisites

Before you can start, you need an application server, or at least an EJB container to which you will deploy your beans. To summarize from my first article, BEA's WebLogic is the most popular commercial application server, but pricey unless your company is large enough. JBoss is the most popular Open Source EJB container and can be combined with a servlet/JSP container (such as Tomcat or Jetty) to form a complete application server. If you have WebLogic, you're ready to go; otherwise, download the current version (2.0—final as of this writing) of JBoss.

Furthermore, you're going to need to be able to configure a database for JBoss to use. I'll be using SQL Server and the Inet Sprinta2000 driver for this example; you can use any database that you like. The JBoss Web site describes how to configure a database but I'll give you a quick summary:

  1. Copy your database driver JAR file to JBoss's lib/ext directory:
  2. sprinta2000.jar
  3. Modify the jboss.properties file to include your driver by entering the name of your JDBC driver at the end of the jdbc.drivers line (replace the characters in bold with your driver):
  4. jdbc.drivers=org.hsql.jdbcDriver,
    org.enhydra.instantdb.jdbc.idbDriver,com.inet.tds.TdsDriver
  5. Modify the jboss.conf file to create a database connection pool (SQLServerPool):
  6. <MLET CODE="org.jboss.jdbc.XADataSourceLoader"
          ARCHIVE="jboss.jar,sprinta2000.jar" 
          CODEBASE="../../lib/ext/">
        <ARG TYPE="java.lang.String" VALUE="SQLServerPool">
        <ARG TYPE="java.lang.String" 
             VALUE="org.jboss.minerva.xa.XADataSourceImpl">
    </MLET>
  7. Modify the jboss.jcml file to tell JBoss how to connect to the database when creating the pool—URL, username (sa in this case), and password (none):
  8. <mbean name="DefaultDomain:service=XADataSource,
            name=SQLServerPool">
      <attribute name="Properties"></attribute>
      <attribute name="URL">jdbc:inetdae:localHost?
                       database=informit</attribute>
      <attribute name="GCMinIdleTime">1200000</attribute>
      <attribute name="JDBCUser">sa</attribute>
      <attribute name="MaxSize">10</attribute>
      <attribute name="Password" />
      <attribute name="GCEnabled">false</attribute>
      <attribute name="InvalidateOnError">false</attribute>
      <attribute name="TimestampUsed">false</attribute>
      <attribute name="Blocking">true</attribute>
      <attribute name="GCInterval">120000</attribute>
      <attribute name="IdleTimeout">1800000</attribute>
      <attribute name="IdleTimeoutEnabled">false</attribute>
      <attribute name="LoggingEnabled">false</attribute>
      <attribute name="MaxIdleTimeoutPercent">1.0</attribute>
      <attribute name="MinSize">0</attribute>
    </mbean>

Please refer to the JBoss Web site for more information.

  • + Share This
  • 🔖 Save To Your Account