import org.openhab.persistence.jdbc.internal.dto.ItemVO;
import org.openhab.persistence.jdbc.internal.dto.ItemsVO;
import org.openhab.persistence.jdbc.internal.dto.JdbcPersistenceItemInfo;
+import org.openhab.persistence.jdbc.internal.exceptions.JdbcException;
import org.openhab.persistence.jdbc.internal.exceptions.JdbcSQLException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
return vo;
}
- protected void storeItemValue(Item item, State itemState, @Nullable ZonedDateTime date) throws JdbcSQLException {
+ protected void storeItemValue(Item item, State itemState, @Nullable ZonedDateTime date) throws JdbcException {
logger.debug("JDBC::storeItemValue: item={} state={} date={}", item, itemState, date);
String tableName = getTable(item);
long timerStart = System.currentTimeMillis();
}
}
- protected String getTable(Item item) throws JdbcSQLException {
- int itemId = 0;
- ItemsVO isvo;
- ItemVO ivo;
-
+ protected String getTable(Item item) throws JdbcException {
String itemName = item.getName();
- String tableName = itemNameToTableNameMap.get(itemName);
+ if (!initialized) {
+ throw new JdbcException("Not initialized, unable to find table for item " + itemName);
+ }
// Table already exists - return the name
+ String tableName = itemNameToTableNameMap.get(itemName);
if (!Objects.isNull(tableName)) {
return tableName;
}
- logger.debug("JDBC::getTable: no table found for item '{}' in sqlTables", itemName);
+ logger.debug("JDBC::getTable: no table found for item '{}' in itemNameToTableNameMap", itemName);
+
+ int itemId = 0;
+ ItemsVO isvo;
+ ItemVO ivo;
if (!conf.getTableUseRealCaseSensitiveItemNames()) {
// Create a new entry in items table
import org.openhab.core.types.State;
import org.openhab.core.types.UnDefType;
import org.openhab.persistence.jdbc.internal.dto.ItemsVO;
+import org.openhab.persistence.jdbc.internal.exceptions.JdbcException;
import org.openhab.persistence.jdbc.internal.exceptions.JdbcSQLException;
import org.osgi.framework.BundleContext;
import org.osgi.framework.Constants;
logger.debug("JDBC: Stored item '{}' as '{}' in SQL database at {} in {} ms.", item.getName(), state,
new Date(), System.currentTimeMillis() - timerStart);
}
- } catch (JdbcSQLException e) {
+ } catch (JdbcException e) {
logger.warn("JDBC::store: Unable to store item", e);
}
}