v1.10

Document

How to Start SequoiaDB

Basic Operation

Data Model

Database Management

Aggregation

Index

Replication

Cluster

Connector

Reference

Development

Release Note

FAQ

  • Content
  • Comments
  • History

Java Datasource Introduction

The datasource in the Java Driver provides users a quick access to obtain valid connetions.

The usage of Connection pool

Use the getConnection() method in SequoiadbDatasource Class to get a connectionfrom the connection pool, use the close() method to return the connections back to the pool.When the connections in the pool reach the upper limit, next request will wait for a little while, if there are no idle connections available in the given time, an exception will be thrown out. ConfigOptions Class can set different parameters of the connections. SequoiadbOption Class can set different parameters of the connection pool.

For more details, please check the introduction of related APIs.

Examples:

SequoiadbDatasource ds = null;
Sequoiadb db = null;
ArrayList<String> urls = new ArrayList<String>();
ConfigOptions nwOpt = new ConfigOptions();
// define connection options
SequoiadbOption dsOpt = new SequoiadbOption();
// define connection pool options

urls.add("ubuntu-dev1:11810");
// add connection address(only need to add coord node's address)
urls.add("ubuntu-dev2:11810");
urls.add("ubuntu-dev3:11810");

nwOpt.setConnectTimeout(500);
// set connection timeout(ms)
nwOpt.setMaxAutoConnectRetryTime(0);
// set maximum auto-connection-retry times

// The following are the default setups of SequoiadbOption.
dsOpt.setMaxConnectionNum(500);
// set the maximum number of connections in the pool
dsOpt.setInitConnectionNum(10);
// Initialize the connection pool, set the initial connection number
dsOpt.setDeltaIncCount(10) ;
// when no connections are available in the pool, increases the maximum number of connections
dsOpt.setMaxIdeNum(10);
// set the maximum idle connections when cleaning the extra idle connections periodically
dsOpt.setTimeout(5 * 1000);
// set the time of waiting connections when the number of used connections reaches the upper limit(500)
dsOpt.setAbandonTime(10 * 60 * 1000);
// set the abandon time. A connection will be abandoned when the idle time of a connection is longer than the abandon time.
dsOpt.setRecheckCyclePeriod(1 * 60 * 1000);
// set the cycle period of cleaning the extra idle connections
dsOpt.setRecaptureConnPeriod(10 * 60 * 1000);
// set the cycle period of checking and capturing the abnormal connections

ds = new SequoiadbDatasource(urls, "", "", nwOpt, dsOpt);
// create a connection pool
db = ds.getConnection();
// get connections from the pool
// do something else
// use the connections to finish certain operations
ds.close(db);
please login to comment.
Latest Comment
  • 2015-03-14

About Us

SequoiaDB is a financial-level distributed database vendor and is the first Chinese database listed in Gartner’s Magic Quadrant OPDBMS report. SequoiaDB has recently released version 3.0.
SequoiaDB is now penetrating the vertical sector Financial Industry quickly and had more than 50 banking clients and hundreds of enterprise customers in industries including government, telecommunication, Internet and IoT.

Beijing:
Tower R, No.8 North Star East Road, Chaoyang District, Beijing,China
Guangzhou:
Tower A, No.22 Qinglan Street, Panyu District, Guangzhou,China
Shenzhen:
Tsing Hua Tech Park, Nanshan District, Shenzhen,China
Tel:400-8038-339
E-mail:contact@sequoiadb.com