# Error while creating new sql connection

**URL:** <https://forum.inductiveautomation.com/t/error-while-creating-new-sql-connection/57099>\
**Category:** Ignition\
**Tags:** ignition79\
**Created:** [March 11, 2022, 9:40am UTC](https://forum.inductiveautomation.com/t/error-while-creating-new-sql-connection/57099 "2022-03-11T09:40:07Z")\
**Posts on this page:** 13\
**Page:** 1

<div class="post-metadata">

**Author:** ![Kartik\_I](https://avatars.discourse-cdn.com/v4/letter/k/8c91f0/32.png) [@Kartik\_I](https://forum.inductiveautomation.com/u/Kartik_I)\
**Post date:** [March 11, 2022, 9:40am UTC](https://forum.inductiveautomation.com/t/error-while-creating-new-sql-connection/57099/1 "2022-03-11T09:40:07Z")

</div>

![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/f/b/fbbce85012ccde45c1df688c6842d9f6da1b470e.png)  
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

---

<div class="post-metadata">

**Author:** ![Transistor](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/transistor/32/3380_2.png) [@Transistor](https://forum.inductiveautomation.com/u/Transistor)\
**Post date:** [March 11, 2022, 11:23am UTC](https://forum.inductiveautomation.com/t/error-while-creating-new-sql-connection/57099/2 "2022-03-11T11:23:16Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Kartik\_I](https://avatars.discourse-cdn.com/v4/letter/k/8c91f0/32.png) [@Kartik\_I](https://forum.inductiveautomation.com/u/Kartik_I)\
**Post date:** [March 11, 2022, 4:28pm UTC](https://forum.inductiveautomation.com/t/error-while-creating-new-sql-connection/57099/3 "2022-03-11T16:28:17Z")

</div>

Thanks @Transistor

This is the wrapper log

```auto
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](https://forum.inductiveautomation.com/uploads/short-url/oEB0QzBUtWffUBkW0EVMpyXS2AB.log) (1.4 MB)

Thanks,  
Kartik

---

<div class="post-metadata">

**Author:** ![Transistor](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/transistor/32/3380_2.png) [@Transistor](https://forum.inductiveautomation.com/u/Transistor)\
**Post date:** [March 11, 2022, 5:42pm UTC](https://forum.inductiveautomation.com/t/error-while-creating-new-sql-connection/57099/4 "2022-03-11T17:42:33Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![paul-griffith](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/paul-griffith/32/37249_2.png) [@paul-griffith](https://forum.inductiveautomation.com/u/paul-griffith)\
**Post date:** [March 11, 2022, 5:42pm UTC](https://forum.inductiveautomation.com/t/error-while-creating-new-sql-connection/57099/5 "2022-03-11T17:42:44Z")

</div>

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:

```auto
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)

```

---

<div class="post-metadata">

**Author:** ![Kartik\_I](https://avatars.discourse-cdn.com/v4/letter/k/8c91f0/32.png) [@Kartik\_I](https://forum.inductiveautomation.com/u/Kartik_I)\
**Post date:** [March 12, 2022, 4:04am UTC](https://forum.inductiveautomation.com/t/error-while-creating-new-sql-connection/57099/7 "2022-03-12T04:04:25Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Kartik\_I](https://avatars.discourse-cdn.com/v4/letter/k/8c91f0/32.png) [@Kartik\_I](https://forum.inductiveautomation.com/u/Kartik_I)\
**Post date:** [March 12, 2022, 4:04am UTC](https://forum.inductiveautomation.com/t/error-while-creating-new-sql-connection/57099/8 "2022-03-12T04:04:56Z")

</div>

Thanks @paul-griffith sure I will do it.

---

<div class="post-metadata">

**Author:** ![ataya](https://avatars.discourse-cdn.com/v4/letter/a/f9ae1b/32.png) [@ataya](https://forum.inductiveautomation.com/u/ataya)\
**Post date:** [June 20, 2024, 6:01pm UTC](https://forum.inductiveautomation.com/t/error-while-creating-new-sql-connection/57099/9 "2024-06-20T18:01:31Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Kartik\_I](https://avatars.discourse-cdn.com/v4/letter/k/8c91f0/32.png) [@Kartik\_I](https://forum.inductiveautomation.com/u/Kartik_I)\
**Post date:** [June 24, 2024, 2:54am UTC](https://forum.inductiveautomation.com/t/error-while-creating-new-sql-connection/57099/10 "2024-06-24T02:54:20Z")

</div>

@ataya could you help me with screenshot for your error

---

<div class="post-metadata">

**Author:** ![justinedwards.jle](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/justinedwards.jle/32/37854_2.png) [@justinedwards.jle](https://forum.inductiveautomation.com/u/justinedwards.jle)\
**Post date:** [June 24, 2024, 7:34am UTC](https://forum.inductiveautomation.com/t/error-while-creating-new-sql-connection/57099/11 "2024-06-24T07:34:20Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![ataya](https://avatars.discourse-cdn.com/v4/letter/a/f9ae1b/32.png) [@ataya](https://forum.inductiveautomation.com/u/ataya)\
**Post date:** [June 26, 2024, 8:21pm UTC](https://forum.inductiveautomation.com/t/error-while-creating-new-sql-connection/57099/12 "2024-06-26T20:21:22Z")

</div>

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:

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/3/5/358965baaaa03368a0690c575e939bb92932b949.png)

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](https://us1.discourse-cdn.com/inductiveautomation/original/3X/7/b/7bc4c73a953180d6b62e97fe75a56b90e4d8e294.png)

---

<div class="post-metadata">

**Author:** ![ataya](https://avatars.discourse-cdn.com/v4/letter/a/f9ae1b/32.png) [@ataya](https://forum.inductiveautomation.com/u/ataya)\
**Post date:** [June 26, 2024, 9:14pm UTC](https://forum.inductiveautomation.com/t/error-while-creating-new-sql-connection/57099/13 "2024-06-26T21:14:03Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![justinedwards.jle](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/justinedwards.jle/32/37854_2.png) [@justinedwards.jle](https://forum.inductiveautomation.com/u/justinedwards.jle)\
**Post date:** [June 26, 2024, 9:25pm UTC](https://forum.inductiveautomation.com/t/error-while-creating-new-sql-connection/57099/14 "2024-06-26T21:25:25Z")

</div>

> [@ataya](#):
>
> alter ignition's internal db columns

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](https://support.inductiveautomation.com/hc/en-us).
