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
e899bafb
Commit
e899bafb
authored
17 years ago
by
brinn
Browse files
Options
Downloads
Patches
Plain Diff
minor clean up: more constants, better variable names
SVN: 3320
parent
db0623a1
No related branches found
No related tags found
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/postgresql/PostgreSQLAdminDAO.java
+14
-13
14 additions, 13 deletions
...temsx/cisd/dbmigration/postgresql/PostgreSQLAdminDAO.java
with
14 additions
and
13 deletions
dbmigration/source/java/ch/systemsx/cisd/dbmigration/postgresql/PostgreSQLAdminDAO.java
+
14
−
13
View file @
e899bafb
...
@@ -33,6 +33,7 @@ import ch.systemsx.cisd.common.logging.LogCategory;
...
@@ -33,6 +33,7 @@ import ch.systemsx.cisd.common.logging.LogCategory;
import
ch.systemsx.cisd.common.logging.LogFactory
;
import
ch.systemsx.cisd.common.logging.LogFactory
;
import
ch.systemsx.cisd.common.utilities.FileUtilities
;
import
ch.systemsx.cisd.common.utilities.FileUtilities
;
import
ch.systemsx.cisd.dbmigration.DBUtilities
;
import
ch.systemsx.cisd.dbmigration.DBUtilities
;
import
ch.systemsx.cisd.dbmigration.DatabaseVersionLogDAO
;
import
ch.systemsx.cisd.dbmigration.IDatabaseAdminDAO
;
import
ch.systemsx.cisd.dbmigration.IDatabaseAdminDAO
;
import
ch.systemsx.cisd.dbmigration.IMassUploader
;
import
ch.systemsx.cisd.dbmigration.IMassUploader
;
import
ch.systemsx.cisd.dbmigration.MassUploadFileType
;
import
ch.systemsx.cisd.dbmigration.MassUploadFileType
;
...
@@ -51,9 +52,9 @@ public class PostgreSQLAdminDAO extends SimpleJdbcDaoSupport implements IDatabas
...
@@ -51,9 +52,9 @@ public class PostgreSQLAdminDAO extends SimpleJdbcDaoSupport implements IDatabas
+
"alter database %1$s set default_with_oids = off;"
;
+
"alter database %1$s set default_with_oids = off;"
;
private
static
final
String
CREATE_TABLE_DATABASE_VERSION_LOGS_SQL
=
private
static
final
String
CREATE_TABLE_DATABASE_VERSION_LOGS_SQL
=
"create table
d
atabase
_v
ersion
_logs
(db_version varchar(4) not null, "
"create table
"
+
D
atabase
V
ersion
LogDAO
.
DB_VERSION_LOG
+
"
(db_version varchar(4) not null, "
+
"module_name varchar(250), run_status varchar(10), run_status_timestamp timestamp, "
+
"module_name varchar(250), run_status varchar(10), run_status_timestamp timestamp, "
+
"module_code bytea, run_exception bytea);"
;
+
"module_code bytea, run_exception bytea);"
;
private
static
final
Logger
operationLog
=
LogFactory
.
getLogger
(
LogCategory
.
OPERATION
,
PostgreSQLAdminDAO
.
class
);
private
static
final
Logger
operationLog
=
LogFactory
.
getLogger
(
LogCategory
.
OPERATION
,
PostgreSQLAdminDAO
.
class
);
...
@@ -63,7 +64,7 @@ public class PostgreSQLAdminDAO extends SimpleJdbcDaoSupport implements IDatabas
...
@@ -63,7 +64,7 @@ public class PostgreSQLAdminDAO extends SimpleJdbcDaoSupport implements IDatabas
private
final
String
owner
;
private
final
String
owner
;
private
final
String
database
;
private
final
String
database
Name
;
/**
/**
* Creates an instance.
* Creates an instance.
...
@@ -72,21 +73,21 @@ public class PostgreSQLAdminDAO extends SimpleJdbcDaoSupport implements IDatabas
...
@@ -72,21 +73,21 @@ public class PostgreSQLAdminDAO extends SimpleJdbcDaoSupport implements IDatabas
* @param scriptExecutor An executor for SQL scripts.
* @param scriptExecutor An executor for SQL scripts.
* @param massUploader A class that can perform mass (batch) uploads into database tables.
* @param massUploader A class that can perform mass (batch) uploads into database tables.
* @param owner Owner to be created if it doesn't exist.
* @param owner Owner to be created if it doesn't exist.
* @param database Name of the database.
* @param database
Name
Name of the database.
*/
*/
public
PostgreSQLAdminDAO
(
DataSource
dataSource
,
ISqlScriptExecutor
scriptExecutor
,
IMassUploader
massUploader
,
public
PostgreSQLAdminDAO
(
DataSource
dataSource
,
ISqlScriptExecutor
scriptExecutor
,
IMassUploader
massUploader
,
String
owner
,
String
database
)
String
owner
,
String
database
Name
)
{
{
this
.
scriptExecutor
=
scriptExecutor
;
this
.
scriptExecutor
=
scriptExecutor
;
this
.
massUploader
=
massUploader
;
this
.
massUploader
=
massUploader
;
this
.
owner
=
owner
;
this
.
owner
=
owner
;
this
.
database
=
database
;
this
.
database
Name
=
database
Name
;
setDataSource
(
dataSource
);
setDataSource
(
dataSource
);
}
}
public
String
getDatabaseName
()
public
String
getDatabaseName
()
{
{
return
database
;
return
database
Name
;
}
}
public
void
createOwner
()
public
void
createOwner
()
...
@@ -135,18 +136,18 @@ public class PostgreSQLAdminDAO extends SimpleJdbcDaoSupport implements IDatabas
...
@@ -135,18 +136,18 @@ public class PostgreSQLAdminDAO extends SimpleJdbcDaoSupport implements IDatabas
private
void
createEmptyDatabase
()
private
void
createEmptyDatabase
()
{
{
operationLog
.
info
(
"Try to create empty database '"
+
database
+
"' with owner '"
+
owner
+
"'."
);
operationLog
.
info
(
"Try to create empty database '"
+
database
Name
+
"' with owner '"
+
owner
+
"'."
);
try
try
{
{
getJdbcTemplate
().
execute
(
String
.
format
(
CREATE_DATABASE_SQL_TEMPLATE
,
database
,
owner
));
getJdbcTemplate
().
execute
(
String
.
format
(
CREATE_DATABASE_SQL_TEMPLATE
,
database
Name
,
owner
));
}
catch
(
RuntimeException
ex
)
}
catch
(
RuntimeException
ex
)
{
{
if
(
ex
instanceof
DataAccessException
&&
DBUtilities
.
isDuplicateDatabaseException
((
DataAccessException
)
ex
))
if
(
ex
instanceof
DataAccessException
&&
DBUtilities
.
isDuplicateDatabaseException
((
DataAccessException
)
ex
))
{
{
operationLog
.
warn
(
"Cannot create database '"
+
database
+
"' since it already exists."
);
operationLog
.
warn
(
"Cannot create database '"
+
database
Name
+
"' since it already exists."
);
}
else
}
else
{
{
operationLog
.
error
(
"Failed to create database '"
+
database
+
"'."
,
ex
);
operationLog
.
error
(
"Failed to create database '"
+
database
Name
+
"'."
,
ex
);
throw
ex
;
throw
ex
;
}
}
}
}
...
@@ -156,7 +157,7 @@ public class PostgreSQLAdminDAO extends SimpleJdbcDaoSupport implements IDatabas
...
@@ -156,7 +157,7 @@ public class PostgreSQLAdminDAO extends SimpleJdbcDaoSupport implements IDatabas
{
{
try
try
{
{
getJdbcTemplate
().
execute
(
"drop database "
+
database
);
getJdbcTemplate
().
execute
(
"drop database "
+
database
Name
);
}
catch
(
DataAccessException
ex
)
}
catch
(
DataAccessException
ex
)
{
{
if
(
DBUtilities
.
isDBNotExistException
(
ex
)
==
false
)
if
(
DBUtilities
.
isDBNotExistException
(
ex
)
==
false
)
...
...
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