JBuilder + JBOSS + Oracle9i environment Configuration

Source: Internet
Author: User

Borland JBuilder is a very convenient Java IDE development tool, while JBoss is a good open-source application server, and Oracle 9i is an excellent enterprise-level database. The following describes the J2EE development environment for JBuilder 2005, JBoss 4.0, and Oracle9i in Windows XP.

1. Install the SDK to D: j2sdk1.4.2 _ 06; Method: Double-click to execute the download j2sdk-1_4_2_06-windows-i586-p.exe file, select the installation directory is D: j2sdk1.4.2 _ 06, other default.

2. Install JBOSS by extracting the downloaded jboss-4.0.1RC1.zip file to any directory, such as D: jboss4.0, which contains a series of files and folders. Install jboss in the d: jboss4.0 directory.

3. Set environment variables. In winxp, right-click my computer on the desktop and select Properties, click "advanced"> "environment variables" on the pop-up page, and then click "new" under "system variables" on the pop-up page ", in the displayed window, enter "JAVA_HOME" for "variable name (N)" And enter "D: j2sdk1.4.2 _ 06" in the "variable value (V)" column ". JBOSS_HOME: D: jboss4.0, add Path: "D: j2sdk1.4.2 _ 06in; D: jboss4.0in"

4. Configure JBoss in JBuilder, select Config servers of Tools, select JBoss3 +, select Enable server, and specify Home Directory.

5. Configure and test the Oracle9i data source in JBoss. Oracle has become a very popular enterprise-level database with its stability and reliability. To configure Oracle on Jboss, copy the JDBC driver of Oracle to ClassPath. Copy the JDBC driver (classes111.zipand classes12.zip) to the server/default/lib directory. To use Oracle's transaction processing data source, we also need to copy/docs/examples/jca/oracle-xa-ds.xml to the/server/default/deploy directory. If you are using a non-transactional data source, copy the/docs/examples/jca/oracle-ds.xml file to the/server/default/deploy directory.

Next, we need to modify the oracle-ds.xml configuration file. The modifications are as follows:

<Datasources>

<Local-tx-datasource>

<Jndi-name> OracleDS </jndi-name>

<Connection-url> jdbc: oracle: thin: @ localhost: oradb </connection-url>

<Driver-class> oracle. jdbc. driver. OracleDriver </driver-class>

<User-name> hrms </user-name>

<Password> hrms </password>

<Exception-sorter-class-name> org. jboss. resource. adapter. jdbc. vendor. OracleExceptionSorter

</Exception-sorter-class-name>

<Metadata>

<Type-mapping> Oracle9i </type-mapping>

</Metadata>

</Local-tx-datasource>

</Datasources>

Run the JBoss test to connect to the database:

Create the db_test.war folder in "jboss installation directory serverdefadeploy" and create index. jsp in db_test.war. The content is as follows:

<% @ Page

Language = "java"

ContentType = "text/html; charset = gb2312"

PageEncoding = "GBK"

%>

<% @ Page import = "java. SQL. *, javax. SQL. DataSource, javax. naming. InitialContext" %>

<H3> test JBOSS connection to Oracle 9i database

<H3> Test Oracle Database

<%

InitialContext ctx = new InitialContext ();

DataSource ds = (DataSource) ctx. lookup ("java:/OracleDS ");

Connection conn = ds. getConnection ();

Statement stmt = conn. createStatement ();

ResultSet rs = stmt.exe cuteQuery ("SELECT TO_CHAR (SYSDATE, YYYY-MM-DD HH24: MI: SS) from dual ");

While (rs. next ()){

Out. println (rs. getString (1) + "<br> ");

Out. println ("My name is Justinchen <br> ");

}

Conn. close ();

%>

Create a folder WEB-INF in db_test.war with two file jboss-web.xml and web. xml with the jboss-web.xml content as follows:

<Jboss-web>

</Jboss-web>

The content of web. xml is as follows:

<? Xml version = "1.0"?>

<! DOCTYPE web-app PUBLIC

"-// Sun Microsystems, Inc. // DTD Web Application 2.3 // EN"

Http://java.sun.com/dtd/web-app_2_3.dtd>

<Web-app> </web-app>

Access http: // localhost: 8080/db_test. After successful access, the connection to the database is normal.


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.