01 package wodbupdate;
02
03 import java.sql.*;
04
05
06 public abstract class Update {
07 protected static final int INDEX_OF_UPDATE_NUMBER = Update.class.getName().length();
08 protected Databaseable database;
09
10 public void setDatabase(Databaseable aDatabase) {
11 database = aDatabase;
12 }
13
14 protected void executeSQL(String anSQLString) throws SQLException {
15 database.executeSQL(anSQLString);
16 }
17
18 protected String version() {
19 return getClass().getName().substring(INDEX_OF_UPDATE_NUMBER);
20 }
21
22 public void performUpdate() throws SQLException {
23 System.out.println("performing Update " + version());
24 executeUpdate();
25 }
26
27 abstract protected void executeUpdate() throws SQLException;
28
29 }
|