2.16.1 create-jdbc-connection-pool
Registers a JDBC connection pool.
Synopsis
asadmin [asadmin-options] create-jdbc-connection-pool [--help] [--datasourceclassname=datasourceclassname] [--restype=resourcetype] [--steadypoolsize=poolsize] [--maxpoolsize=maxpoolsize] [--maxwait=maxwaittime] [--poolresize=poolresizelimit] [--idletimeout=idletimeout] [--isolationlevel=isolationlevel] [--isisolationguaranteed={true|false}] [--isconnectvalidatereq={false|true}] [--validationmethod=validationmethod] [--validationtable=validationtable] [--nontransactionalconnections={false|true}] [--validateatmostonceperiod=validationinterval] [--leaktimeout=leaktimeout] [--leakreclaim={false|true}] [--creationretryattempts=creationretryattempts] [--creationretryinterval=creationretryinterval] [--statementtimeout=statementtimeout] [--lazyconnectionenlistment={false|true}] [--lazyconnectionassociation={false|true}] [--driverclassname=jdbcdriverclassname] [--matchconnections={false|true}] [--maxconnectionusagecount=maxconnectionusagecount] [--ping={false|true}] [--pooling={false|true}] [--statementcachesize=statementcachesize] [--validationclassname=validationclassname] [--description description] [--property name=value[:name=value]...] connectionpoolid
Storage location
Application Server installation directory/javaee/glassfish/bin
Function
The create-jdbc-connection-pool subcommand registers a new Java Database Connectivity ("JDBC") software connection pool with the specified JDBC connection pool name.
A JDBC connection pool with authentication can be created by doing the following:
-
Using a --property option to specify a user, password, or other connection information
-
Specifying the connection information in the XML descriptor file.
Specify the following options depending on the database you want to connect to:
-
Specify the following options to connect to Oracle:
Option
Value
Remark
--datasourceclassname
oracle.jdbc.pool.OracleDataSource
Refer to #1.
oracle.jdbc.xa.client.OracleXADataSource
Refer to #2.
--restype
javax.sql.DataSource
Refer to #1.
javax.sql.XADataSource
Refer to #2.
--validationmethod
custom-validation
Refer to #3.
--validationclassname
org.glassfish.api.jdbc.validation.OracleConnectionValidation
Refer to #3.
--property
databaseName
Oracle SID
Refer to #4.
serverName
Oracle-host-name-or-IP-address
Refer to #4.
portNumber
port-number
Refer to #4.
user
user-name
-
password
password
-
driverType
thin
Refer to #4.
url
jdbc:oracle:thin:@Oracle-host-name-or-IP-address:port-number:Oracle SID
Refer to #4.
- #1:
-
Specify this option if the XA transactions must not be used.
- #2:
-
Specify this option if the XA transactions must be used.
- #3:
-
Specify this option only when the connection errors must be detected.
- #4:
-
Specify the four properties (databaseName, serverName, portNumber, and driverType) or url. If you specify both, url takes effect but the other four properties are ignored.
This command is supported in remote mode only.
Precondition
Domain Administration Server (DAS) is running.
Files
Specify the connection information in the XML descriptor when not using the --property option to create a jdbc connection pool.
Arguments
- --help | -?
-
Displays the help text for the subcommand.
- --datasourceclassname=datasourceclassname
-
Specifies the name of the vendor-supplied JDBC datasource resource manager. Any XA or global transactions capable datasource class will implement the javax.sql.XADatasource interface.
Type: String
The following values can be specified:
-
Specify the datasource class name
Default value: N/A
-
- --restype=resourcetype
-
Indicates when a datasource class implements two or more interfaces (javax.sql.DataSource, javax.sql.XADataSource, or javax.sql.ConnectionPoolDataSource) or when a driver classname must be provided.
If --restype = java.sql.Driver, then the --driverclassname option is required.
If --restype = javax.sql.DataSource, javax.sql.XADataSource, or javax.sql.ConnectionPoolDataSource, then the --datasourceclassname option is required.
If --restype is not specified, then either the --driverclassname or --datasourceclassname option must be specified, but not both.
Type: String
The following values can be specified:
-
java.sql.Driver
-
javax.sql.DataSource
-
javax.sql.XADataSource
-
javax.sql.ConnectionPoolDataSource
Default value: N/A
-
- --steadypoolsize=poolsize
-
Specifies the minimum and initial number of connections maintained in the pool.
Type: Integer
The following values can be specified:
-
0 to 2147483647
Default value: 24
The default value of the steady-pool-size attribute of the connector-connection-pool element of the glassfish-resources.xml file is same as the default value of this option.
-
- --maxpoolsize=maxpoolsize
-
Specifies the maximum number of connections that can be created.
Type: Integer
The following values can be specified:
-
1 to 2147483647
Default value: 24
The default value of the max-pool-size attribute of the connection-pool element is same as the default value of this option.
-
- --maxwait=maxwaittime
-
Specifies the amount of time, in milliseconds, that a caller has to wait for before a connection timeout is sent.
A value of 0 forces the caller to wait indefinitely.
Type: Integer
The following values can be specified:
-
0 to 2147483647
Default value: 60000
-
- --poolresize=poolresizelimit
-
Specifies the number of connections to be removed when idle-timeout-in-seconds timer expires.
Type: Integer
The following values can be specified:
-
1 to 2147483647
Default value: 2
-
- --idletimeout=idletimeout
-
Specifies the maximum time, in seconds, that a connection can remain idle in the pool.
This timeout value must be shorter than the database server side timeout value to prevent the accumulation of unusable connections in the application.
If 0 is specified, then this option is disabled.
Type: Integer
The following values can be specified:
-
0 to 2147483647
Default value: 300
-
- --isolationlevel=isolationlevel
-
Specifies the transaction-isolation-level that can be set on the pooled database connections.
Applications that change the isolation level on a pooled connection programmatically risk polluting the pool. This could lead to program errors.
Type: String
The following values can be specified:
-
read-uncommitted
-
read-committed
-
repeatable-read
-
serializable
Default value: Isolation level set by JDBC driver provider
-
- --isisolationguaranteed={true|false}
-
Applies only when a specific isolation level is specified for the transaction-isolation-level.
Type: Boolean
The following values can be specified:
-
true
-
false
Default value: true
-
- --isconnectvalidatereq={false|true}
-
Validates or checks the connections to see if they are usable before being given out to the application, if set to true.
Type: Boolean
The following values can be specified:
-
true
-
false
Default value: false
-
- --validationmethod=validationmethod
-
Specifies the type of validation to be performed when the --isconnectvalidatereq option is true.
-
If auto-commit is specified: Executes Connection#setAutoCommit(Connection#getAutoCommit()).
-
If meta-data is specified: Executes Connection#getMetaData().
-
If table is specified: Execute the SELECT sentence to the table specified by the --validationtable option.
-
If custom-validation is specified: Execute the user-defined class specified by the --validationclassname option.
Type: String
The following values can be specified:
-
auto-commit
-
meta-data
-
table
-
custom-validation
Default value: table
-
- --validationtable=validationtable
-
Specifies the name of the validation table used to perform a query to validate a connection.
If the --isconnectvalidatereq option is set to true and the --validationmethod set to table, it is mandatory to set this option.
Type: String
The following values can be specified:
-
Specify the validation table name
Default value: N/A
-
- --nontransactionalconnections={false|true}
-
Returns non-transactional connections when a pool with this property is set to true. This connection does not get enlisted automatically with the transaction manager.
Type: Boolean
The following values can be specified:
-
true
-
false
Default value: false
-
- --validateatmostonceperiod=validationinterval
-
Specifies the time interval, in seconds, between successive requests to validate a connection at most once. Setting this attribute to an appropriate value minimizes the number of validation requests by a connection.
If 0 is specified, then the connection is always validated.
Type: Integer
The following values can be specified:
-
0 to 2147483647
Default value: 0
-
- --leaktimeout=leaktimeout
-
Specifies the amount of time, in seconds, for which connection leaks in a connection pool are to be traced. When a connection is not returned to the pool by the application within the specified period, it is assumed to be a potential leak, and the stack trace of the caller will be logged. This option only detects if there is a connection leak. The connection can be reclaimed only if --leakreclaim option is set to true.
Type: Integer
The following values can be specified:
-
0 to 2147483647
Default value: 0
-
- --leakreclaim={false|true}
-
Specifies whether leaked connections are restored to the connection pool after leak connection tracing is complete.
Type: Boolean
The following values can be specified:
-
false
Leaked connections are not restored to the connection pool. This is the default value.
-
true
Leaked connections are restored to the connection pool.
Default value: false
-
- --creationretryattempts=creationretryattempts
-
Specifies the maximum number of times that Java EE Server tries to re-create a connection if the initial attempt fails.
Type: Integer
The following values can be specified:
-
0 to 2147483647
Default value: 0
-
- --creationretryinterval=creationretryinterval
-
Specifies the interval, in seconds, between successive attempts to create a connection.
If --creationretryattempts is 0, the --creationretryinterval option is ignored.
Type: Integer
The following values can be specified:
-
0 to 2147483647
Default value: 10
-
- --statementtimeout=satementleaktimeout
-
Specifies the length of time, in seconds, after which a query that is not completed is terminated.
Type: Integer
The following values can be specified:
-
-1 to 2147483647
Default value: -1
-
- --lazyconnectionenlistment={false|true}
-
Specifies whether a resource to a transaction is enlisted only when a method actually uses the resource.
Type: Boolean
The following values can be specified:
-
false
Resources to a transaction are always enlisted and not only when a method actually uses the resource. This is the default value.
-
true
Resources to a transaction are enlisted only when a method actually uses the resource.
Default value: false
-
- --lazyconnectionassociation={false|true}
-
Specifies that a physical connection should be associated with the logical connection only when the physical connection is used, and disassociated when the transaction is completed. Such association and dissociation enable the reuse of physical connections.
Type: Boolean
The following values can be specified:
-
false
A physical connection is associated with the logical connection even before the physical connection is used, and is not disassociated when the transaction is completed. This is the default value.
-
true
A physical connection is associated with the logical connection only when the physical connection is used, and disassociated when the transaction is completed. The --lazyconnectionenlistment option must also be set to true.
Default value: false
-
- --driverclassname=jdbcdriverclassname
-
Specifies the name of the vendor-supplied JDBC driver class. This driver should implement the java.sql.Driver interface.
Type: String
The following values can be specified:
-
Java class implementing java.sql.Driver interface
Default value: N/A
-
- --matchconnections={false|true}
-
Specifies whether a connection that is selected from the pool should be matched by the resource adaptor.
Type: Boolean
The following values can be specified:
-
false
A connection must not be matched by the resource adaptor. This is the default value.
-
true
A connection must be matched by the resource adaptor. If all the connections in the pool are homogenous, a connection picked from the pool need not be matched by the resource adapter. This means that this option can be set to false.
Default value: false
-
- --maxconnectionusagecount=maxconnectionusagecount
-
Specifies the maximum number of times that a connection can be reused. When this limit is reached, the connection is closed. By limiting the maximum number of times that a connection can be reused, statement leaks can be avoided.
Type: Integer
The following values can be specified:
-
0 to 2147483647
Default value: 0
-
- --ping={false|true}
-
Specifies if the pool is pinged during pool creation or reconfiguration to identify and warn of any erroneous values for its attributes.
Type: Boolean
The following values can be specified:
-
true
-
false
Default value: false
-
- --pooling={false|true}
-
Specifies if connection pooling is enabled for a pool.
Type: Boolean
The following values can be specified:
-
true
-
false
Default value: true
-
- --statementcachesize=statementcachesize
-
Specifies the number of SQL statements to be cached using the default caching mechanism.
Type: Integer
The following values can be specified:
-
0 to 2147483647
Default value: 0
-
- --validationclassname=validationclassname
-
Specifies the name of the class that provides custom validation when the value of --validationmethod is custom-validation. This class must implement the org.glassfish.api.jdbc.ConnectionValidation interface, and it must be accessible to Java EE Server.
This option is mandatory if the connection validation type is set to custom validation.
Type: String
The following values can be specified:
-
Implementers of org.glassfish.api.jdbc.ConnectionValidation interface
Default value: N/A
-
- --description description
-
Specifies the text providing details about the specified JDBC connection pool.
Type: String
The following values can be specified:
-
Specify the description in text
Default value: N/A
-
- --property name=value[:name=value]...
-
Specifies the optional attribute name/value pairs for configuring the pool. The specification format is name=value. Use a colon (:) to separate property names. If you specify the same property name more than once, the property value specified last is valid.
For this option, you can specify the DataSource property supported by the JDBC driver, and a property that is mentioned below. For details on properties that can be specified, see the documentation for the database that you are using.
Type: String
The following values can be specified:
-
user=value
Specifies the user name required to connect to the database.
Type: String
Default value: N/A
Range Value: N/A
-
password=value
Specifies the password required to connect to the database.
Type: String
Default value: N/A
Range Value: N/A
-
databaseName=value
Specifies the database for this connection pool.
Type: String
Default value: N/A
Range Value: N/A
-
serverName=value
Specifies the database server for this connection pool.
Type: String
Default value: N/A
Range Value: N/A
-
portNumber=value
Specifies the port on which the database server listens for requests.
Type: Integer
Default value: N/A
Range Value: 1 to 65535
-
networkProtocol=value
Specifies the communication protocol.
Type: String
Default value: N/A
Range Value: N/A
-
roleName=value
Specifies the initial SQL role name.
Type: String
Default value: N/A
Range Value: N/A
-
datasourceName=value
Specifies an underlying XADataSource or a connectionPoolDataSource if the connection pooling is complete.
Type: String
Default value: N/A
Range Value: N/A
-
description=value
Specifies a text description.
Type: String
Default value: N/A
Range Value: N/A
-
url=value
Specifies the URL for this connection pool. Although this is not a standard property, it is commonly used.
Type: String
Default value: N/A
Range Value: N/A
-
dynamic-reconfiguration-wait-timeout-in-seconds=value
Used to enable dynamic reconfiguration of the connection pool, transparently to the applications that are using the pool, so that applications need not be re-enabled for the attribute or property changes to the pool to take effect. Any in-flight transaction's connection requests will be allowed to complete with the old pool configuration as long as the connection requests are within the timeout period, so as to complete the transaction. New connection requests will wait for the pool reconfiguration to complete and connections will be acquired using the modified pool configuration.
Type: Long
Default value: 0
Range Value: x to y (Where x*1000 is >= -9223372036854775808 and y*1000 is <= 9223372036854775807)
Default value: N/A
-
- connectionpoolid
-
Specifies the name of the JDBC connection pool to be created.
Type: String
The following values can be specified:
-
Specify the connection pool ID
Default value: N/A
-
Examples
The following example creates a jdbc connection pool.
asadmin create-jdbc-connection-pool --datasourceclassname org.apache.derby.jdbc.ClientDataSource --restype javax.sql.XADataSource --property portNumber=1527:password=APP:user=APP:serverName= localhost:databaseName=sun-appserv-samples:connectionAttributes=\; create\\=true sample_derby_pool
Exit Status
Exit Status |
Explanation |
---|---|
0 |
command executed successfully. |
1 |
error in executing the command. |