java.sql.SQLException

Unable to run insert stmt on object MetricsDoubleTypeDevice(sensorVariable=SensorVariable(id=46, sensor=Sensor(id=35, sensorId=0, type=S_LIGHT_LEVEL, name=Photoresistor GL5549 (v4), lastSeen=1471356147821, node=Node(id=12, eui=11, gatewayTable=GatewayTable(id=1, enabled=true, name=mosquitto, networkType=MY_SENSORS, timestamp=1470659030270, state=UP, statusMessage=Connected Successfully, statusSince=1471002435640, type=MQTT, properties={p=, u=, bh=tcp://localhost:1883, tp=mysensors-in, cid=mycontroller-mqtt-client, ts=mysensors-out}), name=LightClass_Test, version=Aug 15 2016 | 19:01:30, type=S_ARDUINO_NODE, libVersion=null, batteryLevel=100, eraseConfig=null, firmware=null, state=UP, lastSeen=1471356147804, rssi=null, properties={}, parentNodeEui=null, registrationState=REGISTERED), room=null, variableTypes=[Light level]), variableType=V_LIGHT_LEVEL, metricType=DOUBLE, timestamp=1471356147829, value=25.0, previousValue=25.0, unitType=U_LIGHT_LEVEL, readOnly=false, offset=0.0, priority=100, graphProperties={color=#ff7f0e, interpolate=linear, subType=line, useGlobal=true, type=lineChart}), timestamp=1471356147829, samples=1, min=null, max=null, avg=25.0, aggregationType=RAW, timestampFrom=null, timestampTo=null): INSERT INTO `metrics_double_type_device` (`sensorVariableId` ,`timestamp` ,`samples` ,`min` ,`max` ,`avg` ,`aggregationType` ) VALUES (?,?,?,?,?,?,?)

Samebug tips1

Check if you're not creating unused SQL entities, as it might cause this exception.


Don't give up yet. Our experts can help. Paste your full stack trace to get a solution.

Solutions on the web14105

  • via GitHub by cimba007
    , 11 months ago
    =GatewayTable(id=1, enabled=true, name=mosquitto, networkType=MY_SENSORS, timestamp=1470659030270, state=UP, statusMessage=Connected Successfully, statusSince=1471002435640, type=MQTT, properties={p=, u=, bh=tcp://localhost:1883, tp=mysensors-in, cid
  • via GitHub by cimba007
    , 11 months ago
    , interpolate=linear, subType=line, useGlobal=true, type=lineChart}), timestamp=1472079176762, samples=1, min=1.0, max=1.0, avg=1.0, aggregationType=RAW, timestampFrom=null, timestampTo=null): INSERT INTO `metrics_double_type_device` (`sensorVariableId` ,`timestamp` ,`samples` ,`min` ,`max` ,`avg` ,`aggregationType` ) VALUES (?,?,?,?,?,?,?)
  • ]), variableType=V_STATUS, metricType=BINARY, timestamp=1472052735738, value=0, previousValue=0, unitType=U_NONE, readOnly=false, offset=0.0, priority=100, graphProperties={color=#ff7f0e, interpolate=linear, subType=line, useGlobal=true, type=lineChart}), timestamp
  • Stack trace

    • java.sql.SQLException: Unable to run insert stmt on object MetricsDoubleTypeDevice(sensorVariable=SensorVariable(id=46, sensor=Sensor(id=35, sensorId=0, type=S_LIGHT_LEVEL, name=Photoresistor GL5549 (v4), lastSeen=1471356147821, node=Node(id=12, eui=11, gatewayTable=GatewayTable(id=1, enabled=true, name=mosquitto, networkType=MY_SENSORS, timestamp=1470659030270, state=UP, statusMessage=Connected Successfully, statusSince=1471002435640, type=MQTT, properties={p=, u=, bh=tcp://localhost:1883, tp=mysensors-in, cid=mycontroller-mqtt-client, ts=mysensors-out}), name=LightClass_Test, version=Aug 15 2016 | 19:01:30, type=S_ARDUINO_NODE, libVersion=null, batteryLevel=100, eraseConfig=null, firmware=null, state=UP, lastSeen=1471356147804, rssi=null, properties={}, parentNodeEui=null, registrationState=REGISTERED), room=null, variableTypes=[Light level]), variableType=V_LIGHT_LEVEL, metricType=DOUBLE, timestamp=1471356147829, value=25.0, previousValue=25.0, unitType=U_LIGHT_LEVEL, readOnly=false, offset=0.0, priority=100, graphProperties={color=#ff7f0e, interpolate=linear, subType=line, useGlobal=true, type=lineChart}), timestamp=1471356147829, samples=1, min=null, max=null, avg=25.0, aggregationType=RAW, timestampFrom=null, timestampTo=null): INSERT INTO `metrics_double_type_device` (`sensorVariableId` ,`timestamp` ,`samples` ,`min` ,`max` ,`avg` ,`aggregationType` ) VALUES (?,?,?,?,?,?,?) at com.j256.ormlite.misc.SqlExceptionUtil.create(SqlExceptionUtil.java:22)[mycontroller-dist-standalone-0.0.3.Alpha2-single.jar:0.0.3.Alpha2] at com.j256.ormlite.stmt.mapped.MappedCreate.insert(MappedCreate.java:135)[mycontroller-dist-standalone-0.0.3.Alpha2-single.jar:0.0.3.Alpha2] at com.j256.ormlite.stmt.StatementExecutor.create(StatementExecutor.java:450)[mycontroller-dist-standalone-0.0.3.Alpha2-single.jar:0.0.3.Alpha2] at com.j256.ormlite.dao.BaseDaoImpl.create(BaseDaoImpl.java:310)[mycontroller-dist-standalone-0.0.3.Alpha2-single.jar:0.0.3.Alpha2] at org.mycontroller.standalone.db.dao.BaseAbstractDaoImpl.create(BaseAbstractDaoImpl.java:184)[mycontroller-dist-standalone-0.0.3.Alpha2-single.jar:0.0.3.Alpha2] at org.mycontroller.standalone.message.McMessageEngine.recordSetTypeData(McMessageEngine.java:838)[mycontroller-dist-standalone-0.0.3.Alpha2-single.jar:0.0.3.Alpha2] at org.mycontroller.standalone.message.McMessageEngine.execute(McMessageEngine.java:116)[mycontroller-dist-standalone-0.0.3.Alpha2-single.jar:0.0.3.Alpha2] at org.mycontroller.standalone.message.McMessageEngine.run(McMessageEngine.java:962)[mycontroller-dist-standalone-0.0.3.Alpha2-single.jar:0.0.3.Alpha2] at java.lang.Thread.run(Thread.java:745)[na:1.8.0_101] Caused by: org.h2.jdbc.JdbcSQLException: Eindeutiger Index oder Primärschlüssel verletzt: "CONSTRAINT_INDEX_4B ON PUBLIC.METRICS_DOUBLE_TYPE_DEVICE(SENSORVARIABLEID, TIMESTAMP, AGGREGATIONTYPE) VALUES ( /* key:340818 */ 46, 1471356147829, null, null, null, null, 0)" Unique index or primary key violation: "CONSTRAINT_INDEX_4B ON PUBLIC.METRICS_DOUBLE_TYPE_DEVICE(SENSORVARIABLEID, TIMESTAMP, AGGREGATIONTYPE) VALUES ( /* key:340818 */ 46, 1471356147829, null, null, null, null, 0)"; SQL statement: INSERT INTO `metrics_double_type_device` (`sensorVariableId` ,`timestamp` ,`samples` ,`min` ,`max` ,`avg` ,`aggregationType` ) VALUES (?,?,?,?,?,?,?) [23505-176] at org.h2.message.DbException.getJdbcSQLException(DbException.java:344)[mycontroller-dist-standalone-0.0.3.Alpha2-single.jar:0.0.3.Alpha2] at org.h2.message.DbException.get(DbException.java:178)[mycontroller-dist-standalone-0.0.3.Alpha2-single.jar:0.0.3.Alpha2] at org.h2.message.DbException.get(DbException.java:154)[mycontroller-dist-standalone-0.0.3.Alpha2-single.jar:0.0.3.Alpha2] at org.h2.index.BaseIndex.getDuplicateKeyException(BaseIndex.java:103)[mycontroller-dist-standalone-0.0.3.Alpha2-single.jar:0.0.3.Alpha2] at org.h2.index.PageBtree.find(PageBtree.java:121)[mycontroller-dist-standalone-0.0.3.Alpha2-single.jar:0.0.3.Alpha2] at org.h2.index.PageBtreeLeaf.addRow(PageBtreeLeaf.java:151)[mycontroller-dist-standalone-0.0.3.Alpha2-single.jar:0.0.3.Alpha2] at org.h2.index.PageBtreeLeaf.addRowTry(PageBtreeLeaf.java:104)[mycontroller-dist-standalone-0.0.3.Alpha2-single.jar:0.0.3.Alpha2] at org.h2.index.PageBtreeNode.addRowTry(PageBtreeNode.java:206)[mycontroller-dist-standalone-0.0.3.Alpha2-single.jar:0.0.3.Alpha2] at org.h2.index.PageBtreeNode.addRowTry(PageBtreeNode.java:206)[mycontroller-dist-standalone-0.0.3.Alpha2-single.jar:0.0.3.Alpha2] at org.h2.index.PageBtreeIndex.addRow(PageBtreeIndex.java:97)[mycontroller-dist-standalone-0.0.3.Alpha2-single.jar:0.0.3.Alpha2] at org.h2.index.PageBtreeIndex.add(PageBtreeIndex.java:88)[mycontroller-dist-standalone-0.0.3.Alpha2-single.jar:0.0.3.Alpha2] at org.h2.table.RegularTable.addRow(RegularTable.java:120)[mycontroller-dist-standalone-0.0.3.Alpha2-single.jar:0.0.3.Alpha2] at org.h2.command.dml.Insert.insertRows(Insert.java:157)[mycontroller-dist-standalone-0.0.3.Alpha2-single.jar:0.0.3.Alpha2] at org.h2.command.dml.Insert.update(Insert.java:115)[mycontroller-dist-standalone-0.0.3.Alpha2-single.jar:0.0.3.Alpha2] at org.h2.command.CommandContainer.update(CommandContainer.java:79)[mycontroller-dist-standalone-0.0.3.Alpha2-single.jar:0.0.3.Alpha2] at org.h2.command.Command.executeUpdate(Command.java:254)[mycontroller-dist-standalone-0.0.3.Alpha2-single.jar:0.0.3.Alpha2] at org.h2.jdbc.JdbcPreparedStatement.executeUpdateInternal(JdbcPreparedStatement.java:158)[mycontroller-dist-standalone-0.0.3.Alpha2-single.jar:0.0.3.Alpha2] at org.h2.jdbc.JdbcPreparedStatement.executeUpdate(JdbcPreparedStatement.java:144)[mycontroller-dist-standalone-0.0.3.Alpha2-single.jar:0.0.3.Alpha2] at com.j256.ormlite.jdbc.JdbcDatabaseConnection.insert(JdbcDatabaseConnection.java:170)[mycontroller-dist-standalone-0.0.3.Alpha2-single.jar:0.0.3.Alpha2] at com.j256.ormlite.stmt.mapped.MappedCreate.insert(MappedCreate.java:91)[mycontroller-dist-standalone-0.0.3.Alpha2-single.jar:0.0.3.Alpha2] ... 7 more

    Write tip

    You have a different solution? A short tip here would help you and many other users who saw this issue last week.

    Users with the same issue

    Once, 1 week ago
    Once, 2 months ago
    3 times, 2 months ago
    3 times, 2 months ago
    4 times, 3 months ago
    143 more bugmates