Configure the JBoss Data Source

Source: Internet
Author: User
Tags jboss server

Configure the JBoss Data Source

Why do I need to configure the JBoss data source in JBoss? This is actually a manifestation of the object-oriented thinking: access to the database through container management.

At first, we accessed the database through JDBC, and we created all the connections and commands. However, every time you open and close the database, it consumes a lot of resources. As a result, a database connection pool is displayed, and a connection to the database is established in advance. When the database is used up, it is retrieved from the connection pool and sent back to the connection pool. This solves the resource consumption problem, but the connection process still needs manual intervention. Later, when we integrated Hibernate with Spring, we came up with the idea of using Spring IOC container to manage Hibernate's access to the database. This process is like using Tomcat to manage the Servlet lifecycle. We only need to use Servlet to submit a message and do not need to worry about when it is created or destroyed. JBoss also manages data sources in the same way.

The problem above is solved, and the problem is solved below.

1. First find the jboss-4.2.3.GA file in the mysql-ds.xml \ docs \ examples \ jca directory (take the mysql data source as an example), copy it to the desktop, edit the mysql-ds.xml file, the content is as follows:

<? Xml version = "1.0" encoding = "UTF-8"?>
<Datasources>
<Local-tx-datasource>
<Jndi-name> itcastDS </jndi-name>
<Connection-url> jdbc: mysql: // mysql-hostname: 3306/test </connection-url>
<Driver-class> com. mysql. jdbc. Driver </driver-class>
<User-name> quwenzhe </user-name>
& Lt; password & gt; 123456 & lt;/password & gt;
<Min-pool-size> 3 </min-pool-size>
<Max-pool-size> 100 </max-pool-size>
<Exception-sorter-class-name> org. jboss. resource. adapter. jdbc. vendor. MySQLExceptionSorter </exception-sorter-class-name>

<Metadata>
<Type-mapping> mySQL </type-mapping>
</Metadata>
</Local-tx-datasource>
</Datasources>

In the mysql-ds.xml file we configure parameters related to mysql database access.

2. Copy the mysql driver jar file to the jboss-4.2.3.GA \ server \ default \ lib directory;

3. Restart the JBoss server;

4. deploy the mysql-ds.xml to the JBoss server: copy the mysql-ds.xml file to the jboss-4.2.3.GA \ server \ default \ deploy directory;

5. Check the JBoss console. If the configured JNDI name can be found in jboss. jca, the data source is successfully configured, as shown in:

You can view the data source parameters in the ManagedConnectionPool.

At this point, the JBoss data source is successfully configured.

Linux Server JBoss running environment setup steps and Automatic startup script compilation and running

RHEL6.5 install OpenJDK1.7.0 + JBoss7.1.1 + Maven3.0.4

Integration of JBoss7.1 and Apache on Enterprise Java Application Server

Run JBoss later in Linux

This article permanently updates the link address:

Related Article

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.