Jetty Server Data Source configuration JNDI-ORACLE,MYSQL,SQLSERVER,DB2, etc.

Source: Internet
Author: User
Tags db2


Download jetty


Download jetty Server (8.1.0.RC2), unzip to any directory
Http://dist.codehaus.org/jetty/jetty-hightide-8.1.0/jetty-hightide-8.1.0.RC2.zip


Creating a configuration file


Create a new Jetty-datasource.xml file and place it in the ${jetty_home}\contexts directory


Configuration file Basic configuration information
<?xml version="1.0"  encoding="UTF-8"?> 
<!DOCTYPE Configure PUBLIC "-//Jetty//Configure//EN" "http://www.eclipse.org/jetty/configure.dtd"> 
<Configure class="org.eclipse.jetty.webapp.WebAppContext"> 
----Data source configuration information for each database----</Configure>
If eclipse integrates the jetty plugin session, creating a configuration file


In the project's Web-inf directory, a new file named Jetty-env.xml, the basic content and the same as above. Note, however, in the button bar of Eclipse, select Run as, or right-click on the project's startup file-run as-configuration, find the jetty about option on the right, click on it, then select the Jetty tab in the left-hand interface, configure the jetty version, Be sure to select Jetty8, then tick the show advanced options below and select Jndi Support-By default the jetty plugin is not supported for Jndi features.


Oracle configuration information
<New id="DSTest" class="org.eclipse.jetty.plus.jndi.Resource">
    <Arg></Arg>
    <Arg>jdbc/DSTest</Arg>
    <Arg>
      <New class="oracle.jdbc.pool.OracleDataSource">
        <Set name="DriverType">thin</Set>
        <Set name="URL">jdbc:oracle:thin:@fmsswdb1:10017:otcd</Set>
        <Set name="User">xxxx</Set>
        <Set name="Password">xxxx</Set>
        <Set name="connectionCachingEnabled">true</Set>
        <Set name="connectionCacheProperties">
          <New class="java.util.Properties">
            <Call name="setProperty">
              <Arg>MinLimit</Arg>
              <Arg>5</Arg>
            </Call>
            <!-- put the other properties in here too -->
          </New>
        </Set>
      </New>
    </Arg>
  </New>




MySQL configuration information
<New id="DSTest" class="org.eclipse.jetty.plus.jndi.Resource">
     <Arg></Arg>
     <Arg>jdbc/DSTest</Arg>
     <Arg>
        <New class="com.mysql.jdbc.jdbc2.optional.MysqlConnectionPoolDataSource">
           <Set name="Url">jdbc:mysql://localhost:3306/databasename</Set>
           <Set name="User">user</Set>
           <Set name="Password">pass</Set>
        </New>
     </Arg>
    </New>




SQL Server configuration information
<New id="DSTest" class="org.eclipse.jetty.plus.jndi.Resource">
     <Arg></Arg>
     <Arg>jdbc/DSTest</Arg>
     <Arg>
        <New class="net.sourceforge.jtds.jdbcx.JtdsDataSource">
           <Set name="User">user</Set>
           <Set name="Password">pass</Set>
           <Set name="DatabaseName">dbname</Set>
           <Set name="ServerName">localhost</Set>
           <Set name="PortNumber">1433</Set>
        </New>
     </Arg>
    </New>




DB2 configuration information
<New id="DSTest" class="org.eclipse.jetty.plus.jndi.Resource">
     <Arg></Arg>
     <Arg>jdbc/DSTest</Arg>
     <Arg>
        <New class="com.ibm.db2.jcc.DB2SimpleDataSource">
           <Set name="DatabaseName">dbname</Set>
           <Set name="User">user</Set>
           <Set name="Password">pass</Set>
           <Set name="ServerName">servername</Set>
           <Set name="PortNumber">50000</Set>
        </New>
     </Arg>
  </New>




Drive Jar Introduction


Put the jar package used in the data source into the ${jetty_home}\lib\ directory, such as using the C3P0 database connection pool and MySQL database, Then put the Mysql-connector-java-5.1.17.jar and C3p0-0.9.1.2.jar in the lib of the jetty container. And then pay attention to class= "Org.eclipse.jetty.plus.jndi.Resource" The name of this class, this class generally exists in the Jetty-plus package, the earliest version is class= " Org.mortbay.jetty.plus.naming.Resource ", Jetty added to Eclipse and became a new org.eclipse.jetty.plus.jndi.Resource.


Website connection pool and data source configuration


Http://wiki.eclipse.org/Jetty/Howto/Configure_JNDI_Datasource






Jetty Server Data Source configuration JNDI-ORACLE,MYSQL,SQLSERVER,DB2, etc.


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.