POM that bundles hsqldb.jar
The following links open the download pages for some popular database products:
Configuring the JDBC Connection Pool Service
Add a configuration for the JDBC Connections Pool service that uses the JDBC driver to create data source objects. Your application code uses this service to obtain the object and connect to the database.
JDBC Connections Pool ( com.day.commons.datasource.jdbcpool.JdbcPoolService
) is a factory service. If you require connections that use different properties, for example read-only or read/write access, create multiple configurations.
When working with CQ there are several methods of managing the configuration settings for such services; see Configuring OSGi for full details.
The following properties are available to configure a pooled connection service. The property names are listed as they appear in the Web Console. The corresponding name for a sling:OsgiConfig
node appears in parentheses. Example values are shown for an HSQLDB server and a database that has an alias of mydb
:
-
JDBC Driver Class (
jdbc.driver.class
): The Java class to use that implements the java.sql.Driver interface, for exampleorg.hsqldb.jdbc.JDBCDriver
. The data type isString
. -
JDBC Connection URI (
jdbc.connection.uri
): The URL of the database to use to create the connection, for examplejdbc:hsqldb:hsql//10.36.79.223:9001/mydb
. The format of the URL must be valid for use with the getConnection method of the java.sql.DriverManager class. The data type isString
. -
Username (
jdbc.username
): The user name to use to authenticate with the database server. The data type isString
. -
Password (
jdbc.password
): The password to use for authentication of the user. The data type isString
. -
Validation Query (
jdbc.validation.query
): The SQL statement to use to verify that the connection is successful, for exampleselect 1 from INFORMATION_SCHEMA.SYSTEM_USERS
. The data type isString
. -
Readonly By Default (default.readonly): Select this option when you want the connection to provide read-only access. The data type is
Boolean
. -
Autocommit By Default (
default.autocommit
): Select this option to create separate transactions for each SQL command that is sent to the database, and each transaction is automatically committed. Do not select this option when you are committing transactions explicitly in your code. The data type isBoolean
. -
Pool Size (
pool.size
): The number of simultaneous connections to be made available to the database. The data type isLong
. -
Pool wait (
pool.max.wait.msec
): The amount of time before a connection request times out. The data type isLong
. -
Datasource Name (
datasource.name
): The name of this data source. The data type isString
. -
Additional Service Properties (
datasource.svc.properties
): A set of name/value pairs that you want to append to the connection URL. The data type isString[]
.
The JDBC Connections Pool service is a factory. Therefore, if you use a sling:OsgiConfig
node to configure the connection service, the name of the node must include the factory service PID followed by -alias
. The alias that you use must be unique for all configuration nodess for that PID. An example node name is com.day.commons.datasource.jdbcpool.JdbcPoolService-myhsqldbpool
.
Connecting to the Database
In your Java code, use the DataSourcePool service to obtain a javax.sql.DataSource
object for the configuration that you created. The DataSourcePool service provides the getDataSource
method that returns a DataSource
object for a given data source name. As the method argument, use the value of the Datasource Name (or datasource.name
) property that you specified for the JDBC Connections Pool configuration.
The following example JSP code obtains an instance of the hsqldbds data source, executes a simple SQL query, and displays the number of results that are returned.
JSP that performs a database lookup
The Perfect Blend: A New Era of Collaboration with AEM and Workfront
Adobe Customer Success Webinars
Wednesday, Apr 2, 5:00 PM UTC
Explore how Adobe Experience Manager and Workfront integrate to help teams move from ideation to delivery without the usual bottlenecks, ensuring content is organized, on-brand, and ready to go live faster.
RegisterRapid Feature Releases with AEM Cloud: Telegraph Media Group’s RDE Strategy
Hear how Telegraph Media Group, the award-winning publisher of The Daily Telegraph, The Sunday Telegraph, The Telegraph Magazine,...
Wed, Mar 19, 3:30 PM PDT (10:30 PM UTC)
How EY Enhanced Regulatory Knowledge Management with Adobe Solutions
Delve into how EY leverages Adobe solutions to enhance regulatory knowledge management. EY leverages search analytics and personalization...
Wed, Mar 19, 4:00 PM PDT (11:00 PM UTC)
Connect with Experience League at Summit!
Get front-row access to top sessions, hands-on activities, and networking—wherever you are!
Learn more