Configuring the JBoss Data source

Source: Internet
Author: User
Tags jboss server

Configure the JBoss data source, why configure the data source in JBoss? This is actually a manifestation of object-oriented thinking: managing access to a database through a container.

At first we accessed the database through JDBC, and what connection and command were created by ourselves. But every time you open the database is consumed resources, so there is a database connection pool, in advance to establish a good connection to the database, use the time to connect pool fetch, used up to send back to the connection pool. This solves the problem of resource consumption, but the connection process still requires manual intervention. Later, when integrating Hibernate with spring, there was the idea of using spring's IOC container to manage Hibernate's access to the database, a process like using Tomcat to manage the servlet's life cycle. We only need to use the servlet to complete the submission of the message, not to care about when it was created, what to destroy, and the JBoss management data source is the same idea.

Above solves the problem of why, the following solution how to do the problem.

1. First locate the Mysql-ds.xml file (for example, MySQL data source) in the JBOSS-4.2.3.GA\DOCS\EXAMPLES\JCA directory and copy it to the desktop. Edit mysql-ds.xml file with the following content:

<?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>    <password>123456</password>    <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 configured the parameters for MySQL database access.

2. Copy the drive jar file that accesses MySQL to the Jboss-4.2.3.ga\server\default\lib directory;

3. Restart the jboss server;

4. Deploy mysql-ds.xml to JBoss server: copy mysql-ds.xml files to jboss-4.2.3.ga\server\default\ Deploy directory;

5. Review the JBoss console, in JBOSS.JCA if you can find the Jndi name of our configuration, the data source configuration is successful, as shown in:


In Managedconnectionpool, you can view the data source parameters that we have configured.

To do this, configure the JBoss data source to succeed.

Configuring the JBoss Data source

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.