public class JDBCConnector extends Object
CREATE TABLE doi_schema.T_DOI_USERS (
username varchar(255) NOT NULL,
admin boolean NOT NULL,
email varchar(255),
PRIMARY KEY (username)
);
CREATE TABLE doi_schema.T_DOI_PROJECT (
suffix int NOT NULL,
projectname varchar(1024) NOT NULL,
PRIMARY KEY (suffix)
);
CREATE TABLE doi_schema.T_DOI_ASSIGNATIONS (
username varchar(255) NOT NULL,
suffix int NOT NULL,
PRIMARY KEY (username, suffix)
);
CREATE TABLE doi_schema.T_DOI_TOKENS (
token varchar(255) NOT NULL,
PRIMARY KEY (token)
);
Modifier and Type | Field and Description |
---|---|
private org.apache.commons.dbcp.BasicDataSource |
dataSource
The data source.
|
static int |
DEFAULT_MAX_ACTIVE_CONNECTION
Default max active connection 50.
|
static int |
DEFAULT_MAX_IDLE_CONNECTION
Default max IDL connection 50.
|
static int |
DEFAULT_MIN_IDLE_CONNECTION
Default min IDL connection 10.
|
private static org.apache.logging.log4j.Logger |
LOGGER
Logger.
|
Constructor and Description |
---|
JDBCConnector(String dbUrl,
String dbUser,
String dbPwd,
Map<String,Integer> options)
Creates the JDBC connector based on a specific configuration file.
|
Modifier and Type | Method and Description |
---|---|
void |
close()
Closes and releases all idle connections that are currently stored in the
connection pool associated with this data source.
|
Connection |
getConnection()
Creates (if necessary) and return a connection to the database.
|
private void |
init(String dbUrl,
String dbUser,
String dbPwd,
Map<String,Integer> options)
Data source initialization.
|
private static final org.apache.logging.log4j.Logger LOGGER
public static final int DEFAULT_MIN_IDLE_CONNECTION
public static final int DEFAULT_MAX_IDLE_CONNECTION
public static final int DEFAULT_MAX_ACTIVE_CONNECTION
private final org.apache.commons.dbcp.BasicDataSource dataSource
private void init(String dbUrl, String dbUser, String dbPwd, Map<String,Integer> options)
dbUrl
- database URLdbUser
- database userdbPwd
- database passwordoptions
- database optionsDoiRuntimeException
- Cannot decrypt the database pwd from the
configuration filepublic Connection getConnection() throws SQLException
SQLException
- if a database access error occurspublic void close()
Copyright © 2017–2020 CNES. All rights reserved.