Jboss4. Mysql data source configuration under 0

Source: Internet
Author: User
It took an hour to figure out jboss4. Configure the mysql data source at 0. The following are some specific processes:
1. First install the mysql database and test its driver to serverdefalib Lib of jboss.
2. Place the mysql-ds.xml file under serverdefadedeploy
The content is as follows:
<Datasources>
<Local-tx-datasource>
<Jndi-name> MySqlDS </jndi-name>
<Connection-url> jdbc: mysql: /localhost: 3306/test </connection-url>
<Driver-class> org. gjt. mm. mysql. Driver </driver-class>
<User-name> root </user-name>
<Password> qwe123 </password>
<! -- Corresponding type-mapping in the standardjbosscmp-jdbc.xml (optional) -->
<Metadata>
<Type-mapping> mySQL </type-mapping>
</Metadata>
</Local-tx-datasource>
</Datasources>
3. Create your own war package testds. war
Contains META-INF/jbosscmp-jdbc.xml, reload default data sources
<Jbosscmp-jdbc>
<Defaults>
<Datasource> java:/MySqlDS </datasource>
<Datasource-mapping> mySql </datasource-mapping>
</Defaults>
</Jbosscmp-jdbc>
4. Create a servlet for testing and put it in the package above
Package test;
Import java. io. IOException;
Import javax. servlet. ServletException;
Import javax. servlet. http. HttpServlet;
Import javax. servlet. http. HttpServletRequest;
Import javax. servlet. http. HttpServletResponse;
Import java. SQL .*;
Import javax. naming .*;
Import javax. SQL .*;
Import java. io .*;
/**
* @ Author Administrator
*
* TODO To change the template for this generated type comment go
* Window-Preferences-Java-Code Style-Code Templates
*/
Public class myservlet extends HttpServlet {
/* (Non-Javadoc)
* @ See javax. servlet. http. HttpServlet # doGet (javax. servlet. http. HttpServletRequest, javax. servlet. http. HttpServletResponse)
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.