| | 136 | public void setInfo(String key, String value) throws IDMapperException |
| | 137 | { |
| | 138 | try |
| | 139 | { |
| | 140 | /** |
| | 141 | * This is a bit awkward because we store keys as columns. |
| | 142 | * TODO: in a future schema version this should be a regular 2-column table. |
| | 143 | */ |
| | 144 | if (!key.matches("^\\w+$")) throw new IllegalArgumentException("key: '" + key + "' contains invalid characters"); |
| | 145 | PreparedStatement pstInfo1 = con.prepareStatement ( |
| | 146 | "ALTER TABLE info " + |
| | 147 | "ADD COLUMN " + key + " VARCHAR (50)" |
| | 148 | ); |
| | 149 | pstInfo1.execute(); |
| | 150 | PreparedStatement pstInfo2 = con.prepareStatement ( |
| | 151 | "UPDATE info SET " + key + " = ? " + |
| | 152 | "WHERE schemaversion = " + GDB_COMPAT_VERSION |
| | 153 | ); |
| | 154 | pstInfo2.setString(1, value); |
| | 155 | pstInfo2.execute(); |
| | 156 | } |
| | 157 | catch (SQLException ex) |
| | 158 | { |
| | 159 | throw new IDMapperException(ex); |
| | 160 | } |
| | 161 | } |
| | 162 | |