[Schmitzm-commits] r2131 - trunk/schmitzm-core/src/main/java/de/schmitzm/versionnumber
scm-commit at wald.intevation.org
scm-commit at wald.intevation.org
Sat Nov 10 17:05:38 CET 2012
Author: mojays
Date: 2012-11-10 17:05:38 +0100 (Sat, 10 Nov 2012)
New Revision: 2131
Modified:
trunk/schmitzm-core/src/main/java/de/schmitzm/versionnumber/ReleaseControl.java
Log:
ReleaseControl: automatic table creation only on table update, not on table read (because of maybe missing admin rights on normal login!)
Modified: trunk/schmitzm-core/src/main/java/de/schmitzm/versionnumber/ReleaseControl.java
===================================================================
--- trunk/schmitzm-core/src/main/java/de/schmitzm/versionnumber/ReleaseControl.java 2012-11-09 14:54:05 UTC (rev 2130)
+++ trunk/schmitzm-core/src/main/java/de/schmitzm/versionnumber/ReleaseControl.java 2012-11-10 16:05:38 UTC (rev 2131)
@@ -163,10 +163,7 @@
expProgrVersion = rs.getString(getRequiredReleaseColName());
rs.close();
} catch (SQLException err) {
- LOGGER.warn("Parameters table '"+getParametersTableName()+"' does not exist. Try to create table...");
- // Error executing the query -> table does not exist
- // -> create table
- createParametersTable(conn);
+ LOGGER.warn("Parameters table '"+getParametersTableName()+"' does not exist.");
}
return expProgrVersion;
}
@@ -223,7 +220,8 @@
}
/**
- * Creates a parameters table in database schema.
+ * Creates a parameters table in database schema. Method expects that
+ * connection provides admin rights on database!
* @param conn connection used to create the table
*/
protected void createParametersTable(Connection conn) throws SQLException {
@@ -257,7 +255,8 @@
}
/**
- * Updates the required application release number in database.
+ * Updates the required application release number in database. Method expects that
+ * connection provides admin rights on database!
* @param conn connection used to update the table
* @param reqVersion build number to set
*/
@@ -265,8 +264,16 @@
PreparedStatement stmt = conn.prepareStatement("UPDATE "+getParametersTableName()+
" SET "+getRequiredReleaseColName()+" = ?");
stmt.setString(1, reqVersion);
- stmt.execute();
- conn.commit();
+ try {
+ stmt.execute();
+ conn.commit();
+ } catch (Exception err) {
+ LOGGER.error("Error updating required application release in database: "+err.getMessage());
+ LOGGER.error("Maybe parameters table '"+getParametersTableName()+"' does not exist. Try to created.");
+ // Error executing the query -> table does not exist
+ // -> create table
+ createParametersTable(conn);
+ }
}
More information about the Schmitzm-commits
mailing list