dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #36643
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 18744: Startup routine fix
------------------------------------------------------------
revno: 18744
committer: Lars Helge Overland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Mon 2015-03-30 13:01:39 +0200
message:
Startup routine fix
modified:
dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/startup/InitTableAlteror.java
--
lp:dhis2
https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk
Your team DHIS 2 developers is subscribed to branch lp:dhis2.
To unsubscribe from this branch go to https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk/+edit-subscription
=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/startup/InitTableAlteror.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/startup/InitTableAlteror.java 2015-03-30 07:56:29 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/startup/InitTableAlteror.java 2015-03-30 11:01:39 +0000
@@ -79,9 +79,7 @@
private void upgradeProgramStageDataElements()
{
- int r = executeSql( "select 1 from programstage_dataelements" );
-
- if ( r != -1 )
+ if ( tableExists( "programstage_dataelements" ) )
{
String autoIncr = statementBuilder.getAutoIncrementValue();
@@ -104,8 +102,6 @@
{
try
{
- // TODO use jdbcTemplate
-
return statementManager.getHolder().executeUpdate( sql );
}
catch ( Exception ex )
@@ -115,4 +111,17 @@
return -1;
}
}
+
+ private boolean tableExists( String table )
+ {
+ try
+ {
+ statementManager.getHolder().queryForInteger( "select 1 from " + table );
+ return true;
+ }
+ catch ( Exception ex )
+ {
+ return false;
+ }
+ }
}