Error while creating new sql connection


Hello All,

  Please help me out with this issue I am getting this error when I am trying to make new sql connection.

Thanks,
Kartik

Tip: paste the error as code using the </> formatting button. That way we can copy the query into our answers and edit it.

You have somehow managed to post your “Please help me …” as code which means it gets a scroll bar underneath it. You can fix this using the edit button (pencil icon) and preview before submitting.

Can you post

  1. the script that generates the SQL INSERT and
  2. explain what the for syntax is doing
  3. the error recorded in the log? Got to Gateway | Status | Diagnostics | Logs.

Post each as code rather than as a screengrab.

1 Like

Thanks @Transistor

This is the wrapper log

INFO   | jvm 1    | 2022/03/11 14:40:39 | E [c.i.i.g.w.c.AbstractRecordEditPanel] [09:10:39]: Error updating Database Connection "DB". 
INFO   | jvm 1    | 2022/03/11 14:40:39 | simpleorm.utils.SException$Jdbc: Executing INSERT INTO DATASOURCES (DATASOURCES_ID, Name, Description, DriverId, TranslatorId, ConnectURL, Username, PasswordE, ConnectionProps) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?) for [DatasourceRecord 3 NewRecord Dirty0]
INFO   | jvm 1    | 2022/03/11 14:40:39 | 	at simpleorm.sessionjdbc.SSessionJdbcHelper.flushExecuteUpdate(SSessionJdbcHelper.java:434)
INFO   | jvm 1    | 2022/03/11 14:40:39 | 	at simpleorm.sessionjdbc.SSessionJdbcHelper.flush(SSessionJdbcHelper.java:400)
INFO   | jvm 1    | 2022/03/11 14:40:39 | 	at simpleorm.sessionjdbc.SSessionJdbc.flush(SSessionJdbc.java:459)
INFO   | jvm 1    | 2022/03/11 14:40:39 | 	at simpleorm.sessionjdbc.SSessionJdbc.flush(SSessionJdbc.java:443)
INFO   | jvm 1    | 2022/03/11 14:40:39 | 	at simpleorm.sessionjdbc.SSessionJdbc.commitAndDetachDataSet(SSessionJdbc.java:382)
INFO   | jvm 1    | 2022/03/11 14:40:39 | 	at com.inductiveautomation.ignition.gateway.web.components.AbstractRecordEditPanel.commitRecords(AbstractRecordEditPanel.java:203)
INFO   | jvm 1    | 2022/03/11 14:40:39 | 	at com.inductiveautomation.ignition.gateway.web.components.AbstractRecordEditPanel.onSubmit(AbstractRecordEditPanel.java:155)
INFO   | jvm 1    | 2022/03/11 14:40:39 | 	at com.inductiveautomation.ignition.gateway.web.components.AbstractRecordEditPanel.onSubmit(AbstractRecordEditPanel.java:122)
INFO   | jvm 1    | 2022/03/11 14:40:39 | 	at com.inductiveautomation.ignition.gateway.web.components.RecordEditForm$1.onSubmitInternal(RecordEditForm.java:92)
INFO   | jvm 1    | 2022/03/11 14:40:39 | 	at com.inductiveautomation.ignition.gateway.web.components.CsrfPreventingForm.onSubmit(CsrfPreventingForm.java:66)
INFO   | jvm 1    | 2022/03/11 14:40:39 | 	at org.apache.wicket.markup.html.form.Form$9.component(Form.java:1248)
INFO   | jvm 1    | 2022/03/11 14:40:39 | 	at org.apache.wicket.markup.html.form.Form$9.component(Form.java:1242)
INFO   | jvm 1    | 2022/03/11 14:40:39 | 	at org.apache.wicket.util.visit.Visits.visitPostOrderHelper(Visits.java:274)
INFO   | jvm 1    | 2022/03/11 14:40:39 | 	at org.apache.wicket.util.visit.Visits.visitPostOrder(Visits.java:245)
INFO   | jvm 1    | 2022/03/11 14:40:39 | 	at org.apache.wicket.markup.html.form.Form.delegateSubmit(Form.java:1241)
INFO   | jvm 1    | 2022/03/11 14:40:39 | 	at org.apache.wicket.markup.html.form.Form.process(Form.java:923)
INFO   | jvm 1    | 2022/03/11 14:40:39 | 	at org.apache.wicket.markup.html.form.Form.onFormSubmitted(Form.java:769)
INFO   | jvm 1    | 2022/03/11 14:40:39 | 	at org.apache.wicket.markup.html.form.Form.onFormSubmitted(Form.java:702)
INFO   | jvm 1    | 2022/03/11 14:40:39 | 	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
INFO   | jvm 1    | 2022/03/11 14:40:39 | 	at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
INFO   | jvm 1    | 2022/03/11 14:40:39 | 	at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
INFO   | jvm 1    | 2022/03/11 14:40:39 | 	at java.lang.reflect.Method.invoke(Unknown Source)
INFO   | jvm 1    | 2022/03/11 14:40:39 | 	at org.apache.wicket.RequestListenerInterface.internalInvoke(RequestListenerInterface.java:258)
INFO   | jvm 1    | 2022/03/11 14:40:39 | 	at org.apache.wicket.RequestListenerInterface.invoke(RequestListenerInterface.java:216)
INFO   | jvm 1    | 2022/03/11 14:40:39 | 	at org.apache.wicket.core.request.handler.ListenerInterfaceRequestHandler.invokeListener(ListenerInterfaceRequestHandler.java:240)
INFO   | jvm 1    | 2022/03/11 14:40:39 | 	at org.apache.wicket.core.request.handler.ListenerInterfaceRequestHandler.respond(ListenerInterfaceRequestHandler.java:226)
INFO   | jvm 1    | 2022/03/11 14:40:39 | 	at org.apache.wicket.request.cycle.RequestCycle$HandlerExecutor.respond(RequestCycle.java:814)
INFO   | jvm 1    | 2022/03/11 14:40:39 | 	at org.apache.wicket.request.RequestHandlerStack.execute(RequestHandlerStack.java:64)
INFO   | jvm 1    | 2022/03/11 14:40:39 | 	at org.apache.wicket.request.cycle.RequestCycle.execute(RequestCycle.java:253)
INFO   | jvm 1    | 2022/03/11 14:40:39 | 	at org.apache.wicket.request.cycle.RequestCycle.processRequest(RequestCycle.java:210)
INFO   | jvm 1    | 2022/03/11 14:40:39 | 	at org.apache.wicket.request.cycle.RequestCycle.processRequestAndDetach(RequestCycle.java:281)
INFO   | jvm 1    | 2022/03/11 14:40:39 | 	at org.apache.wicket.protocol.http.WicketFilter.processRequest(WicketFilter.java:188)
INFO   | jvm 1    | 2022/03/11 14:40:39 | 	at org.apache.wicket.protocol.http.WicketFilter.doFilter(WicketFilter.java:245)
INFO   | jvm 1    | 2022/03/11 14:40:39 | 	at com.inductiveautomation.ignition.gateway.bootstrap.SRFilter.doFilter(SRFilter.java:80)
INFO   | jvm 1    | 2022/03/11 14:40:39 | 	at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1596)
INFO   | jvm 1    | 2022/03/11 14:40:39 | 	at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:545)
INFO   | jvm 1    | 2022/03/11 14:40:39 | 	at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:143)
INFO   | jvm 1    | 2022/03/11 14:40:39 | 	at org.eclipse.jetty.security.SecurityHandler.handle(SecurityHandler.java:590)
INFO   | jvm 1    | 2022/03/11 14:40:39 | 	at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:127)
INFO   | jvm 1    | 2022/03/11 14:40:39 | 	at org.eclipse.jetty.server.handler.ScopedHandler.nextHandle(ScopedHandler.java:235)
INFO   | jvm 1    | 2022/03/11 14:40:39 | 	at org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:1607)
INFO   | jvm 1    | 2022/03/11 14:40:39 | 	at org.eclipse.jetty.server.handler.ScopedHandler.nextHandle(ScopedHandler.java:233)
INFO   | jvm 1    | 2022/03/11 14:40:39 | 	at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1297)
INFO   | jvm 1    | 2022/03/11 14:40:39 | 	at org.eclipse.jetty.server.handler.ScopedHandler.nextScope(ScopedHandler.java:188)
INFO   | jvm 1    | 2022/03/11 14:40:39 | 	at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:485)
INFO   | jvm 1    | 2022/03/11 14:40:39 | 	at org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:1577)
INFO   | jvm 1    | 2022/03/11 14:40:39 | 	at org.eclipse.jetty.server.handler.ScopedHandler.nextScope(ScopedHandler.java:186)
INFO   | jvm 1    | 2022/03/11 14:40:39 | 	at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1212)
INFO   | jvm 1    | 2022/03/11 14:40:39 | 	at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:141)
INFO   | jvm 1    | 2022/03/11 14:40:39 | 	at org.eclipse.jetty.server.handler.HandlerList.handle(HandlerList.java:59)
INFO   | jvm 1    | 2022/03/11 14:40:39 | 	at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:127)
INFO   | jvm 1    | 2022/03/11 14:40:39 | 	at org.eclipse.jetty.server.Server.handle(Server.java:500)
INFO   | jvm 1    | 2022/03/11 14:40:39 | 	at org.eclipse.jetty.server.HttpChannel.lambda$handle$1(HttpChannel.java:383)
INFO   | jvm 1    | 2022/03/11 14:40:39 | 	at org.eclipse.jetty.server.HttpChannel.dispatch(HttpChannel.java:547)
INFO   | jvm 1    | 2022/03/11 14:40:39 | 	at org.eclipse.jetty.server.HttpChannel.handle(HttpChannel.java:375)
INFO   | jvm 1    | 2022/03/11 14:40:39 | 	at org.eclipse.jetty.server.HttpConnection.onFillable(HttpConnection.java:270)
INFO   | jvm 1    | 2022/03/11 14:40:39 | 	at org.eclipse.jetty.io.AbstractConnection$ReadCallback.succeeded(AbstractConnection.java:311)
INFO   | jvm 1    | 2022/03/11 14:40:39 | 	at org.eclipse.jetty.io.FillInterest.fillable(FillInterest.java:103)
INFO   | jvm 1    | 2022/03/11 14:40:39 | 	at org.eclipse.jetty.io.ChannelEndPoint$2.run(ChannelEndPoint.java:117)
INFO   | jvm 1    | 2022/03/11 14:40:39 | 	at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.runTask(EatWhatYouKill.java:336)
INFO   | jvm 1    | 2022/03/11 14:40:39 | 	at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.doProduce(EatWhatYouKill.java:313)
INFO   | jvm 1    | 2022/03/11 14:40:39 | 	at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.tryProduce(EatWhatYouKill.java:171)
INFO   | jvm 1    | 2022/03/11 14:40:39 | 	at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.run(EatWhatYouKill.java:129)
INFO   | jvm 1    | 2022/03/11 14:40:39 | 	at org.eclipse.jetty.util.thread.ReservedThreadExecutor$ReservedThread.run(ReservedThreadExecutor.java:388)
INFO   | jvm 1    | 2022/03/11 14:40:39 | 	at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:806)
INFO   | jvm 1    | 2022/03/11 14:40:39 | 	at org.eclipse.jetty.util.thread.QueuedThreadPool$Runner.run(QueuedThreadPool.java:938)
INFO   | jvm 1    | 2022/03/11 14:40:39 | 	at java.lang.Thread.run(Unknown Source)
INFO   | jvm 1    | 2022/03/11 14:40:39 | Caused by: org.sqlite.SQLiteException: [SQLITE_CONSTRAINT_PRIMARYKEY]  A PRIMARY KEY constraint failed (UNIQUE constraint failed: DATASOURCES.DATASOURCES_ID)
INFO   | jvm 1    | 2022/03/11 14:40:39 | 	at org.sqlite.core.DB.newSQLException(DB.java:909)
INFO   | jvm 1    | 2022/03/11 14:40:39 | 	at org.sqlite.core.DB.newSQLException(DB.java:921)
INFO   | jvm 1    | 2022/03/11 14:40:39 | 	at org.sqlite.core.DB.execute(DB.java:825)
INFO   | jvm 1    | 2022/03/11 14:40:39 | 	at org.sqlite.core.DB.executeUpdate(DB.java:863)
INFO   | jvm 1    | 2022/03/11 14:40:39 | 	at org.sqlite.jdbc3.JDBC3PreparedStatement.executeUpdate(JDBC3PreparedStatement.java:102)
INFO   | jvm 1    | 2022/03/11 14:40:39 | 	at com.inductiveautomation.ignition.gateway.localdb.DelegatingDataSource$DelegatingConnection$DelegatingPreparedStatement.executeUpdate(DelegatingDataSource.java:585)
INFO   | jvm 1    | 2022/03/11 14:40:39 | 	at simpleorm.sessionjdbc.SSessionJdbcHelper.flushExecuteUpdate(SSessionJdbcHelper.java:432)
INFO   | jvm 1    | 2022/03/11 14:40:39 | 	... 66 common frames omitted

Please find the attached wrapper log for your refernce

wrapper.log (1.4 MB)

Thanks,
Kartik

That’s item 3 of the information request. What about items 1 and 2?

Contact support. Something’s gone wrong with your internal database. Likely only an issue on whatever specific 7.9.X version you’re on; this seems familiar:

INFO   | jvm 1    | 2022/03/11 14:40:39 | Caused by: org.sqlite.SQLiteException: [SQLITE_CONSTRAINT_PRIMARYKEY]  A PRIMARY KEY constraint failed (UNIQUE constraint failed: DATASOURCES.DATASOURCES_ID)

Hello @Transistor

  1. For Type 1 I am unaware because I couldn’t find out from where is it generating the SQL insert It’s just creating the issue whenever I am trying to create the SQL new connection via JDBC driver.

  2. I am not able to find this.

Thanks
Kartik

Thanks @PGriffith sure I will do it.

Hi, I know this is an old post but I came across a similar problem at 8.1.35.

Did you get a solution for this? Can you share if you don't mind?

I have a similar issue when trying to add a realtime tag provider. Basically, the ignition sequence counter, wherever that is, goes out of sync, and tries to write to database with an id that already exists. For my case, it is trying to create a record with id 114, which exists, and the current id sequence is supposed to be at 158 instead.

If you found the solution with the support, and if you don't mind sharing it here, I'd appreciate it. Thanks.

@ataya could you help me with screenshot for your error

Simply set the database's ID column to auto increment, and then, leave the ID out of the insert statement.

Edit: I figured I just sent out error logs from datasources table, but this is the most recent one I got, and I have exact same NewRecord Dirty0 errors on other gateways when adding the tag providers. I am curious if you got a solution back then?

Thank you @Kartik_I

This is from scripting using system.db.addDatasource():
Executing INSERT INTO DATASOURCES (DATASOURCES_ID) VALUES (?) for [DatasourceRecord 3 NewRecord Dirty0

and this is from the gateway:

And same in the logs:
simpleorm.utils.SException$Jdbc: Executing INSERT INTO DATASOURCES (DATASOURCES_ID, Name, Description, DriverId, TranslatorId, ConnectURL, Username, PasswordE, ConnectionProps) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?) for [DatasourceRecord 3 NewRecord Dirty

Also the IDs in the DATASOURCES table; max is 4, compared to 3 that it is trying to insert...
image

Thanks @justinedwards.jle, do you know how to alter ignition's internal db columns to be auto-increment, and change ignition's built-in functions to not include ID while inserting, if they are included?

When you put it that way,, it stops sounding like a good idea. I didn't realize you're talking about the internal database. I don't recommend altering that. It's starting to sound like this issue should be escalated to support.

3 Likes