mirror of
https://github.com/openhab/openhab-addons.git
synced 2025-01-25 14:55:55 +01:00
Fixed ClassCastException; Update mariadb-java-client to version 1.4.6 (#8883)
Signed-off-by: Christoph Weitkamp <github@christophweitkamp.de>
This commit is contained in:
parent
4cd2a5b314
commit
9992a67990
@ -28,7 +28,7 @@
|
||||
<derby.version>10.12.1.1</derby.version>
|
||||
<h2.version>1.4.191</h2.version>
|
||||
<hsqldb.version>2.3.3</hsqldb.version>
|
||||
<mariadb.version>1.3.5</mariadb.version>
|
||||
<mariadb.version>1.4.6</mariadb.version>
|
||||
<mysql.version>8.0.13</mysql.version>
|
||||
<postgresql.version>9.4.1212</postgresql.version>
|
||||
<sqlite.version>3.16.1</sqlite.version>
|
||||
|
@ -62,9 +62,9 @@ import org.slf4j.LoggerFactory;
|
||||
public class JdbcBaseDAO {
|
||||
private final Logger logger = LoggerFactory.getLogger(JdbcBaseDAO.class);
|
||||
|
||||
public Properties databaseProps = new Properties();
|
||||
public final Properties databaseProps = new Properties();
|
||||
protected String urlSuffix = "";
|
||||
public Map<String, String> sqlTypes = new HashMap<>();
|
||||
public final Map<String, String> sqlTypes = new HashMap<>();
|
||||
|
||||
// Get Database Meta data
|
||||
protected DbMetaData dbMeta;
|
||||
@ -318,12 +318,12 @@ public class JdbcBaseDAO {
|
||||
}
|
||||
|
||||
public void doStoreItemValue(Item item, ItemVO vo) {
|
||||
vo = storeItemValueProvider(item, vo);
|
||||
ItemVO storedVO = storeItemValueProvider(item, vo);
|
||||
String sql = StringUtilsExt.replaceArrayMerge(sqlInsertItemValue,
|
||||
new String[] { "#tableName#", "#tablePrimaryValue#" },
|
||||
new String[] { vo.getTableName(), sqlTypes.get("tablePrimaryValue") });
|
||||
Object[] params = new Object[] { vo.getValue(), vo.getValue() };
|
||||
logger.debug("JDBC::doStoreItemValue sql={} value='{}'", sql, vo.getValue());
|
||||
new String[] { storedVO.getTableName(), sqlTypes.get("tablePrimaryValue") });
|
||||
Object[] params = new Object[] { storedVO.getValue(), storedVO.getValue() };
|
||||
logger.debug("JDBC::doStoreItemValue sql={} value='{}'", sql, storedVO.getValue());
|
||||
Yank.execute(sql, params);
|
||||
}
|
||||
|
||||
@ -402,17 +402,17 @@ public class JdbcBaseDAO {
|
||||
String it = getSqlTypes().get(itemType);
|
||||
if (it.toUpperCase().contains("DOUBLE")) {
|
||||
vo.setValueTypes(it, java.lang.Double.class);
|
||||
Number newVal = ((DecimalType) item.getState());
|
||||
Number newVal = (Number) item.getState();
|
||||
logger.debug("JDBC::storeItemValueProvider: newVal.doubleValue: '{}'", newVal.doubleValue());
|
||||
vo.setValue(newVal.doubleValue());
|
||||
} else if (it.toUpperCase().contains("DECIMAL") || it.toUpperCase().contains("NUMERIC")) {
|
||||
vo.setValueTypes(it, java.math.BigDecimal.class);
|
||||
DecimalType newVal = ((DecimalType) item.getState());
|
||||
DecimalType newVal = (DecimalType) item.getState();
|
||||
logger.debug("JDBC::storeItemValueProvider: newVal.toBigDecimal: '{}'", newVal.toBigDecimal());
|
||||
vo.setValue(newVal.toBigDecimal());
|
||||
} else if (it.toUpperCase().contains("INT")) {
|
||||
vo.setValueTypes(it, java.lang.Integer.class);
|
||||
Number newVal = ((DecimalType) item.getState());
|
||||
Number newVal = (Number) item.getState();
|
||||
logger.debug("JDBC::storeItemValueProvider: newVal.intValue: '{}'", newVal.intValue());
|
||||
vo.setValue(newVal.intValue());
|
||||
} else {// fall back to String
|
||||
@ -423,7 +423,7 @@ public class JdbcBaseDAO {
|
||||
}
|
||||
} else if ("ROLLERSHUTTERITEM".equals(itemType) || "DIMMERITEM".equals(itemType)) {
|
||||
vo.setValueTypes(getSqlTypes().get(itemType), java.lang.Integer.class);
|
||||
Number newVal = ((DecimalType) item.getState());
|
||||
Number newVal = (DecimalType) item.getState();
|
||||
logger.debug("JDBC::storeItemValueProvider: newVal.intValue: '{}'", newVal.intValue());
|
||||
vo.setValue(newVal.intValue());
|
||||
} else if ("DATETIMEITEM".equals(itemType)) {
|
||||
|
@ -12,6 +12,7 @@
|
||||
*/
|
||||
package org.openhab.persistence.jdbc.internal;
|
||||
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.util.Collections;
|
||||
import java.util.Enumeration;
|
||||
import java.util.Map;
|
||||
@ -243,12 +244,11 @@ public class JdbcConfiguration {
|
||||
|
||||
logger.debug("JDBC::updateConfig: Init Data Access Object Class: '{}'", ddp);
|
||||
try {
|
||||
dBDAO = (JdbcBaseDAO) Class.forName(ddp).newInstance();
|
||||
dBDAO = (JdbcBaseDAO) Class.forName(ddp).getConstructor().newInstance();
|
||||
logger.debug("JDBC::updateConfig: dBDAO ClassName={}", dBDAO.getClass().getName());
|
||||
} catch (InstantiationException e) {
|
||||
logger.error("JDBC::updateConfig: InstantiationException: {}", e.getMessage());
|
||||
} catch (IllegalAccessException e) {
|
||||
logger.error("JDBC::updateConfig: IllegalAccessException: {}", e.getMessage());
|
||||
} catch (IllegalAccessException | InstantiationException | InvocationTargetException
|
||||
| NoSuchMethodException e) {
|
||||
logger.error("JDBC::updateConfig: Exception: {}", e.getMessage());
|
||||
} catch (ClassNotFoundException e) {
|
||||
logger.warn("JDBC::updateConfig: no Configuration for serviceName '{}' found. ClassNotFoundException: {}",
|
||||
serviceName, e.getMessage());
|
||||
@ -294,21 +294,21 @@ public class JdbcConfiguration {
|
||||
e.getMessage());
|
||||
String warn = ""
|
||||
+ "\n\n\t!!!\n\tTo avoid this error, place an appropriate JDBC driver file for serviceName '{}' in addons directory.\n"
|
||||
+ "\tCopy missing JDBC-Driver-jar to your OpenHab/addons Folder.\n\t!!!\n" + "\tDOWNLOAD: \n";
|
||||
+ "\tCopy missing JDBC-Driver-jar to your openHab/addons Folder.\n\t!!!\n" + "\tDOWNLOAD: \n";
|
||||
if (serviceName.equals("derby")) {
|
||||
warn += "\tDerby: version >= 10.11.1.1 from http://mvnrepository.com/artifact/org.apache.derby/derby\n";
|
||||
warn += "\tDerby: version >= 10.11.1.1 from https://mvnrepository.com/artifact/org.apache.derby/derby\n";
|
||||
} else if (serviceName.equals("h2")) {
|
||||
warn += "\tH2: version >= 1.4.189 from http://mvnrepository.com/artifact/com.h2database/h2\n";
|
||||
warn += "\tH2: version >= 1.4.189 from https://mvnrepository.com/artifact/com.h2database/h2\n";
|
||||
} else if (serviceName.equals("hsqldb")) {
|
||||
warn += "\tHSQLDB: version >= 2.3.3 from http://mvnrepository.com/artifact/org.hsqldb/hsqldb\n";
|
||||
warn += "\tHSQLDB: version >= 2.3.3 from https://mvnrepository.com/artifact/org.hsqldb/hsqldb\n";
|
||||
} else if (serviceName.equals("mariadb")) {
|
||||
warn += "\tMariaDB: version >= 1.2.0 from http://mvnrepository.com/artifact/org.mariadb.jdbc/mariadb-java-client\n";
|
||||
warn += "\tMariaDB: version >= 1.2.0 from https://mvnrepository.com/artifact/org.mariadb.jdbc/mariadb-java-client\n";
|
||||
} else if (serviceName.equals("mysql")) {
|
||||
warn += "\tMySQL: version >= 5.1.36 from http://mvnrepository.com/artifact/mysql/mysql-connector-java\n";
|
||||
warn += "\tMySQL: version >= 5.1.36 from https://mvnrepository.com/artifact/mysql/mysql-connector-java\n";
|
||||
} else if (serviceName.equals("postgresql")) {
|
||||
warn += "\tPostgreSQL:version >= 9.4.1208 from http://mvnrepository.com/artifact/org.postgresql/postgresql\n";
|
||||
warn += "\tPostgreSQL:version >= 9.4.1208 from https://mvnrepository.com/artifact/org.postgresql/postgresql\n";
|
||||
} else if (serviceName.equals("sqlite")) {
|
||||
warn += "\tSQLite: version >= 3.16.1 from http://mvnrepository.com/artifact/org.xerial/sqlite-jdbc\n";
|
||||
warn += "\tSQLite: version >= 3.16.1 from https://mvnrepository.com/artifact/org.xerial/sqlite-jdbc\n";
|
||||
}
|
||||
logger.warn(warn, serviceName);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user