private void createVersionTable(final Connection conn) throws SQLException { String versionTableName = getVersionTableName(); if (!JdbcUtils.tableExists(versionTableName, conn)) { try (Statement stmt = conn.createStatement()) { stmt.execute(String.format("CREATE TABLE %s" + " (version varchar(10) PRIMARY KEY ," + " version_time %s)", versionTableName, _sqlTimestampType)); } updateVersion(conn, ModelVersion.fromString(BrokerModel.MODEL_VERSION)); } }
private ModelVersion getStoredVersion() throws SQLException { ModelVersion version = null; try (Connection connection = getConnection(); Statement statement = connection.createStatement(); ResultSet resultSet = statement.executeQuery(String.format("SELECT version FROM %s", getVersionTableName()))) { while (resultSet.next()) { ModelVersion storedVersion = ModelVersion.fromString(resultSet.getString(1)); if (version == null || version.lessThan(storedVersion)) { version = storedVersion; } } } if (version == null) { throw new StoreException("Version of links is not found"); } return version; }
try ModelVersion version = ModelVersion.fromString(versionString); if (storedVersion == null || storedVersion.lessThan(version))
createPreferencesTable(connection); ModelVersion preferencesVersion = getPreferencesVersion(connection); ModelVersion brokerModelVersion = ModelVersion.fromString(BrokerModel.MODEL_VERSION); if (brokerModelVersion.lessThan(preferencesVersion))
ModelVersion storedVersion = ModelVersion.fromString(storeContent.getVersion()); ModelVersion currentVersion = new ModelVersion(BrokerModel.MODEL_MAJOR_VERSION, BrokerModel.MODEL_MINOR_VERSION);
ModelVersion getStoredVersion() { try(Cursor cursor = getPreferencesVersionDb().openCursor(null, null)) { DatabaseEntry key = new DatabaseEntry(); DatabaseEntry value = new DatabaseEntry(); ModelVersion storedVersion = null; while (cursor.getNext(key, value, LockMode.READ_UNCOMMITTED) == OperationStatus.SUCCESS) { String versionString = StringBinding.entryToString(key); ModelVersion version = ModelVersion.fromString(versionString); if (storedVersion == null || storedVersion.lessThan(version)) { storedVersion = version; } } if (storedVersion == null) { throw new StoreException("No preference version information."); } return storedVersion; } catch (RuntimeException e) { throw getEnvironmentFacade().handleDatabaseException("Cannot visit preference version", e); } }
private ModelVersion getStoredVersion() throws RuntimeException { try(Cursor cursor = getLinksVersionDb().openCursor(null, null)) { DatabaseEntry key = new DatabaseEntry(); DatabaseEntry value = new DatabaseEntry(); ModelVersion storedVersion = null; while (cursor.getNext(key, value, LockMode.READ_UNCOMMITTED) == OperationStatus.SUCCESS) { String versionString = StringBinding.entryToString(key); ModelVersion version = ModelVersion.fromString(versionString); if (storedVersion == null || storedVersion.lessThan(version)) { storedVersion = version; } } if (storedVersion == null) { throw new StoreException("No link version information."); } return storedVersion; } catch (RuntimeException e) { throw getEnvironmentFacade().handleDatabaseException("Cannot visit link version", e); } }