Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
O
openbis
Manage
Activity
Members
Labels
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
sispub
openbis
Commits
300efd53
Commit
300efd53
authored
12 years ago
by
brinn
Browse files
Options
Downloads
Patches
Plain Diff
Add additional options to fine-tune operations for query sources.
SVN: 26743
parent
86d244d6
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
dbmigration/source/java/ch/systemsx/cisd/dbmigration/SimpleDatabaseConfigurationContext.java
+47
-14
47 additions, 14 deletions
.../cisd/dbmigration/SimpleDatabaseConfigurationContext.java
with
47 additions
and
14 deletions
dbmigration/source/java/ch/systemsx/cisd/dbmigration/SimpleDatabaseConfigurationContext.java
+
47
−
14
View file @
300efd53
...
...
@@ -24,7 +24,8 @@ import org.apache.commons.dbcp.BasicDataSource;
import
org.springframework.beans.factory.DisposableBean
;
import
ch.systemsx.cisd.base.exceptions.CheckedExceptionTunnel
;
import
ch.systemsx.cisd.common.utilities.PropertyUtils
;
import
static
ch
.
systemsx
.
cisd
.
common
.
utilities
.
PropertyUtils
.*;
/**
* Configuration context for database operations.
...
...
@@ -49,9 +50,20 @@ public class SimpleDatabaseConfigurationContext implements DisposableBean
static
final
String
PASSWORD_KEY
=
"database-password"
;
static
final
String
MAX_IDLE_KEY
=
"database-max-idle"
;
static
final
String
MAX_IDLE_KEY
=
"database-max-idle-connections"
;
static
final
String
MAX_ACTIVE_KEY
=
"database-max-active-connections"
;
static
final
String
MAX_WAIT_FOR_CONNECTION
=
"database-max-wait-for-connection"
;
static
final
String
ACTIVE_CONNECTIONS_LOG_INTERVAL
=
"database-active-connections-log-interval"
;
static
final
String
ACTIVE_NUMBER_CONNECTIONS_LOG_THRESHOLD
=
"database-active-number-connections-log-threshold"
;
static
final
String
MAX_ACTIVE_KEY
=
"database-max-active"
;
static
final
String
LOG_STACKTRACE_ON_CONNECTION_LOGGING
=
"database.log-stacktrace-on-connection-logging"
;
static
final
String
VALIDATION_QUERY_KEY
=
"validation-query"
;
...
...
@@ -82,26 +94,47 @@ public class SimpleDatabaseConfigurationContext implements DisposableBean
public
SimpleDatabaseConfigurationContext
(
Properties
properties
)
{
this
.
driverClassName
=
PropertyUtils
.
getMandatoryProperty
(
properties
,
DRIVER_KEY
);
this
.
url
=
PropertyUtils
.
getMandatoryProperty
(
properties
,
URL_KEY
);
this
.
driverClassName
=
getMandatoryProperty
(
properties
,
DRIVER_KEY
);
this
.
url
=
getMandatoryProperty
(
properties
,
URL_KEY
);
this
.
username
=
PropertyUtils
.
getProperty
(
properties
,
USER_KEY
,
System
.
getProperty
(
"user.name"
)
getProperty
(
properties
,
USER_KEY
,
System
.
getProperty
(
"user.name"
)
.
toLowerCase
());
this
.
password
=
PropertyUtils
.
getProperty
(
properties
,
PASSWORD_KEY
);
this
.
password
=
getProperty
(
properties
,
PASSWORD_KEY
);
if
(
hasProperty
(
properties
,
MAX_ACTIVE_KEY
))
{
dataSourceFactory
.
setMaxActive
(
getInt
(
properties
,
MAX_ACTIVE_KEY
,
-
1
));
}
if
(
hasProperty
(
properties
,
MAX_IDLE_KEY
))
{
dataSourceFactory
.
setMaxIdle
(
getInt
(
properties
,
MAX_IDLE_KEY
,
-
1
));
}
if
(
hasProperty
(
properties
,
MAX_WAIT_FOR_CONNECTION
))
{
dataSourceFactory
.
setMaxWait
(
getInt
(
properties
,
MAX_WAIT_FOR_CONNECTION
,
-
1
));
}
if
(
hasProperty
(
properties
,
ACTIVE_CONNECTIONS_LOG_INTERVAL
))
{
dataSourceFactory
.
setActiveConnectionsLogInterval
(
getInt
(
properties
,
ACTIVE_CONNECTIONS_LOG_INTERVAL
,
-
1
));
}
int
maxActive
=
PropertyUtils
.
getInt
(
properties
,
MAX_ACTIVE_KEY
,
-
1
);
if
(
maxActive
!=
-
1
)
if
(
hasProperty
(
properties
,
ACTIVE_NUMBER_CONNECTIONS_LOG_THRESHOLD
))
{
dataSourceFactory
.
setMaxActive
(
maxActive
);
dataSourceFactory
.
setActiveNumConnectionsLogThreshold
(
getInt
(
properties
,
ACTIVE_NUMBER_CONNECTIONS_LOG_THRESHOLD
,
-
1
));
}
int
maxIdle
=
PropertyUtils
.
getInt
(
properties
,
MAX_IDLE_KEY
,
-
1
);
if
(
maxIdle
!=
-
1
)
if
(
hasProperty
(
properties
,
LOG_STACKTRACE_ON_CONNECTION_LOGGING
))
{
dataSourceFactory
.
setMaxIdle
(
maxIdle
);
dataSourceFactory
.
setLogStackTraceOnConnectionLogging
(
getBoolean
(
properties
,
LOG_STACKTRACE_ON_CONNECTION_LOGGING
,
false
));
}
this
.
validationQuery
=
PropertyUtils
.
getProperty
(
properties
,
VALIDATION_QUERY_KEY
);
this
.
validationQuery
=
getProperty
(
properties
,
VALIDATION_QUERY_KEY
);
}
/**
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment