The configuration of the JBoss data source

Source: Internet
Author: User
Tags mssqlserver jboss jboss server

JBoss has a default data source Defaultds, and he uses the JBoss built-in HSQLDB database. In practical applications you may use different databases, such as MySQL, MSSQLServer, Oracle, and so on. Data source configuration templates for various databases you can find in the Jboss installation directory]/DOCS/EXAMPLES/JCA directory, the default name is: Database name +-ds.xml. Whether you use that database or not, you need to place his driver class jar pack in the JBoss installation directory]/server/default/lib directory and start the JBoss server after placement.

The database used for this example is mysql-5.0.22 and Ms Sql Server2000, using the driver jar package as follows:

Mysql:mysql-connector-java-3.1.13-bin.jar Ms Sql Server2000:msbase.jar, Mssqlserver.jar, Msutil.jar.

The following describes the MySQL and Ms Sql Server2000 data Source configuration, the data source configuration file name format must be xxx–ds.xml, such as: Mysql-ds.xml, Mssqlserver-ds.xml,oracle-ds.xml.

When the data source file is configured, it needs to be placed in the [JBoss installation directory]/server/config-name/deploy directory, this tutorial uses the configuration name: default, so the path is [JBoss installation directory]/server/default/ Deploy directory

MySql Data Source Configuration

Below defines a MySQL data source named Defaultmysqlds, the connection database is Zhaosoft, the database login user name is root, the password is admin, the database drive class is org.gjt.mm.mysql.Driver. All you need to modify the database name and login username password can be used directly.

Mysql-ds.xml

<?xml version= "1.0" encoding= "UTF-8"?>

<datasources>

<local-tx-datasource>

<jndi-name>zhaosoft</jndi-name>

<connection-url>jdbc:mysql://localhost:3306/foshanshop?useunicode=true&amp;characterencoding=gbk

</connection-url>

<driver-class>org.gjt.mm.mysql.Driver</driver-class>

<user-name>root</user-name>

<password>admin</password>

<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>

Configuration of Ms Sql Server2000 Data source

The following defines an MS SQL Server data source named Mssqlds, the connection database is Foshanshop, the database logon username is SA, the password is SA, The database-driven class is com.microsoft.jdbc.sqlserver.SQLServerDriver. We only need to modify the database name and login username, password can be used directly.

Mssqlserver-ds.xml

<?xml version= "1.0" encoding= "UTF-8"?>

<datasources>

<local-tx-datasource>

<jndi-name>zhaosoft</jndi-name>

<connection-url>jdbc:microsoft:sqlserver://Localhost:1433;databasename=foshanshop </connection-url>

<driver-class>com.microsoft.jdbc.sqlserver.SQLServerDriver</driver-class>

<user-name>sa</user-name>

<password>sa</password>

<metadata>

<type-mapping>ms sqlserver2000</type-mapping>

</metadata>

</local-tx-datasource>

</datasources>

oralce9i the data source configuration

The following defines a oracle9i data source named Oracleds, the connection database is FS, the database login username is root, the password is admin, and the database-driven class is oracle.jdbc.driver.OracleDriver. All you need to modify the database name and login username password can be used directly.

Oracle-ds.xml

<?xml version= "1.0" encoding= "UTF-8"?>

<datasources>

<local-tx-datasource>

<jndi-name>zhaosoft</jndi-name>

<connection-url>jdbc:oracle:thin: @nd:1521:fs</connection-url>

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

<user-name>root</user-name>

<password>admin</password>

<SetBigStringTryClob>true</SetBigStringTryClob>

<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>

After the data source is released, you can find him in http://localhost:8080/jmx-console/, as shown in the following figure:

You can click Name=defaultmysqlds,service=managedconnectionpool to enter the connection pool property modification interface. Where the MaxSize property specifies the maximum number of connections, Inuseconnectioncount represents the number of connections currently in use, and once Inuseconnectioncount is greater than maxsize, the database connection will error. This situation is generally due to the manual operation of JDBC, after the use of no immediate release of the connection caused.

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.