jboss7.1.0 configuration database (MySQL)

Source: Internet
Author: User
Tags jboss

Take jboss7.1.0 and MySQL for example

1, find the installation directory, my directory is: jboss-as-7.1.0.cr1b

2, find Standalone.xml, this file on my computer is C:\Users\dan\Desktop\jboss-as-7.1.0.CR1b\standalone\configuration

3, open, and search datasources

4. Make edits

<datasources>

<datasource jndi-name= "java:jboss/datasources/exampleds" pool-name= "Exampleds_pooll"

Enabled= "true" Jta= "true" use-java-context= "true" use-ccm= "true" >

<connection-url>jdbc:mysql://localhost:3306/DBName</connection-url>

<driver>mysql</driver>

<pool>

<min-pool-size>5</min-pool-size>

<max-pool-size>10</max-pool-size>

<prefill>true</prefill>

<use-strict-min></use-strict-min>

</pool>

<security>

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

<password>123456</password>

</security>

<statement>

<track-statements>true</track-statements>

<prepared-statement-cache-size>10</prepared-statement-cache-size>

</statement>

<timeout>

<idle-timeout-minutes>10</idle-timeout-minutes>

<query-timeout>600</query-timeout>

</timeout>

</datasource>

<drivers>

<driver name= "MySQL" module= "Com.mysql" >

<driver-class>com.mysql.jdbc.Driver</driver-class> <xa-datasource-class> Com.mysql.jdbc2.optional.mysqlxadatasource</xa-datasource-class>

</driver>

</drivers>

</datasources>

5, to the E:\jboss-as-7.1.0.CR1b\modules\com folder under the new MySQL, enter a new main folder in the entry, put the database. Jar in.

6. Create a new Module.xml in this E:\jboss-as-7.1.0.CR1b\modules\com\mysql\main folder

7. Open Module.xml for editing

<module xmlns= "urn:jboss:module:1.1" name= "Com.mysql" >

<resources>

<resource-root path= "Mysql-connector-java-5.0.5-bin.jar"/>

</resources>

<dependencies>

<module name= "Javax.api"/>

<module name= "Javax.transaction.api"/>

</dependencies>

</module>

Remember: path is the same as your database jar

8. Use in the Web

<%

Context c=new InitialContext ();

DataSource datasource= (DataSource) c.lookup ("Java:jboss/datasources/exampleds");

Connection conn=datasource.getconnection ();

PreparedStatement Pstm=null;

ResultSet Rs=null;

try{

Pstm=conn.preparestatement ("Select *from Score");

Rs=pstm.executequery ();

while (Rs.next ()) {

Out.println (Rs.getint (1) + "<br>");

}

}catch (Exception e) {}

%>

jboss7.1.0 configuration database (MySQL)

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.