官术网_书友最值得收藏!

Step 1: Creating a data source

The first step is to define a data source inside the enterprise application. A data source represents a pool of JDBC connections to a specific database that will be used later by the persistence APIs. A data source is identified by a JNDI name, and includes JDBC connection information. To declare your data source in GlassFish, you should create a glassfish-resources.xml file in the WEB-INF folder for your project, as shown in the following file:

/WEB-INF/glassfish-resources.xml 
<?xml version="1.0" encoding="UTF-8"?> 
<!DOCTYPE resources PUBLIC "-//GlassFish.org//DTD GlassFish Application Server 3.1 Resource Definitions//EN" "http://glassfish.org/dtds/glassfish-resources_1_5.dtd"> 
<resources> 
    <jdbc-connection-pool allow-non-component-callers="false" associate-with-thread="false" connection-creation-retry-attempts="0" connection-creation-retry-interval-in-seconds="10" connection-leak-reclaim="false" connection-leak-timeout-in-seconds="0" connection-validation-method="auto-commit" datasource-classname="com.mysql.jdbc.jdbc2.optional.MysqlDataSource" fail-all-connections="false" idle-timeout-in-seconds="300" is-connection-validation-required="false" is-isolation-level-guaranteed="true" lazy-connection-association="false" lazy-connection-enlistment="false" match-connections="false" max-connection-usage-count="0" max-pool-size="32" max-wait-time-in-millis="60000" name="mysql_cinemasapp_rootPool" non-transactional-connections="false" pool-resize-quantity="2" res-type="javax.sql.DataSource" statement-timeout-in-seconds="-1" steady-pool-size="8" validate-atmost-once-period-in-seconds="0" wrap-jdbc-objects="false"> 
        <property name="serverName" value="localhost"/> 
        <property name="portNumber" value="3306"/> 
        <property name="databaseName" value="cinemasapp"/> 
        <property name="User" value="root"/> 
        <property name="Password" value="root"/> 
        <property name="URL" value="jdbc:mysql://localhost:3306/cinemasapp?zeroDateTimeBehavior=convertToNull"/> 
        <property name="driverClass" value="com.mysql.jdbc.Driver"/> 
    </jdbc-connection-pool> 
    <jdbc-resource enabled="true" jndi-name="java:app/cinemasapp-ds" object-type="user" pool-name="mysql_cinemasapp_rootPool"/> 
</resources> 
主站蜘蛛池模板: 辽阳市| 施秉县| 洛浦县| 青州市| 织金县| 察哈| 虞城县| 吴江市| 安溪县| 崇州市| 潮安县| 苏州市| 盐城市| 娄烦县| 房山区| 平泉县| 乐安县| 兴国县| 安化县| 集安市| 石阡县| 东源县| 龙州县| 乐昌市| 湾仔区| 元江| 九台市| 徐闻县| 青阳县| 修水县| 翁牛特旗| 南木林县| 绥江县| 长宁县| 噶尔县| 乌什县| 额尔古纳市| 山阳县| 华容县| 汉沽区| 阿拉善左旗|