# Error says table has no primary key, but primary key exists

**URL:** <https://forum.servoy.com/t/error-says-table-has-no-primary-key-but-primary-key-exists/17396>\
**Category:** Classic Servoy\
**Created:** [August 15, 2013, 1:04pm UTC](https://forum.servoy.com/t/error-says-table-has-no-primary-key-but-primary-key-exists/17396 "2013-08-15T13:04:34Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![deezzub](https://avatars.discourse-cdn.com/v4/letter/d/dec6dc/32.png) [@deezzub](https://forum.servoy.com/u/deezzub)\
**Post date:** [August 15, 2013, 1:04pm UTC](https://forum.servoy.com/t/error-says-table-has-no-primary-key-but-primary-key-exists/17396/1 "2013-08-15T13:04:34Z")

</div>

After update to Servoy Developer 7.2 on Windows 7 64 bit, I get error messages like the following:

```auto
Relation "mitarbeiter_to_mitarbeiterkfz" is referring to a foreign table "mitarbeiterkfz" on server "boss_db" but the foreign table does not have a primary key.

```

but the table has a primary key. For example If I change the id _Row Ident_ to nothing and save and then back to row\_ident and save the error message is gone. After I have closed Servoy Developer and open it again I often get error messages like this, but based on other tables.

[attachment=0]2013-08-15 14\_37\_45-no\_primary\_key\_error.png[/attachment]

 ![2013-08-15 14_37_45-no_primary_key_error.png](https://canada1.discourse-cdn.com/flex010/uploads/servoy/original/2X/b/bc30dac9f975db35c3d33dcd4f85dcd2c83c4856.png)

---

<div class="post-metadata">

**Author:** ![sbutler](https://yyz2.discourse-cdn.com/flex010/user_avatar/forum.servoy.com/sbutler/32/4393_2.png) [@sbutler](https://forum.servoy.com/u/sbutler)\
**Post date:** [August 16, 2013, 3:07pm UTC](https://forum.servoy.com/t/error-says-table-has-no-primary-key-but-primary-key-exists/17396/2 "2013-08-16T15:07:57Z")

</div>

it may be a bug, but the larger question is why doesn’t your table have Primary Keys? using row\_ident should only be used if your connecting to a database that doesn’t have the concept of a PK (like FileMaker). Otherwise your db should declare the PK, and Servoy will recognize it.

---

<div class="post-metadata">

**Author:** ![deezzub](https://avatars.discourse-cdn.com/v4/letter/d/dec6dc/32.png) [@deezzub](https://forum.servoy.com/u/deezzub)\
**Post date:** [August 22, 2013, 8:59am UTC](https://forum.servoy.com/t/error-says-table-has-no-primary-key-but-primary-key-exists/17396/3 "2013-08-22T08:59:36Z")

</div>

> goldcougar:  
> it may be a bug, but the larger question is why doesn’t your table have Primary Keys? using row\_ident should only be used if your connecting to a database that doesn’t have the concept of a PK (like FileMaker). Otherwise your db should declare the PK, and Servoy will recognize it.

There are FoxPro / dBase tables.

---

<div class="post-metadata">

**Author:** ![deezzub](https://avatars.discourse-cdn.com/v4/letter/d/dec6dc/32.png) [@deezzub](https://forum.servoy.com/u/deezzub)\
**Post date:** [August 26, 2013, 3:38pm UTC](https://forum.servoy.com/t/error-says-table-has-no-primary-key-but-primary-key-exists/17396/4 "2013-08-26T15:38:18Z")

</div>

Also I get the following error, which solved like the error above.

[attachment=0]2013-08-26 17\_27\_02-Servoy\_Developer\_valuelist\_error.png[/attachment]

 ![2013-08-26 17_27_02-Servoy_Developer_valuelist_error.png](https://canada1.discourse-cdn.com/flex010/uploads/servoy/original/2X/0/08f5a1ade03e62a39d97f4ea80107ec8859b8e52.png)

---

<div class="post-metadata">

**Author:** ![kwpsd](https://avatars.discourse-cdn.com/v4/letter/k/bb73d2/32.png) [@kwpsd](https://forum.servoy.com/u/kwpsd)\
**Post date:** [August 26, 2013, 8:58pm UTC](https://forum.servoy.com/t/error-says-table-has-no-primary-key-but-primary-key-exists/17396/5 "2013-08-26T20:58:19Z")

</div>

For Servoy to connect to VFP .DBF tables, the .DBF tables themselves must contain a PK column:

1. USE tablename
2. COPY TO tablename\_temp
3. MODI STRU
4. Column name: PK, Type: Autoinc(Integer)
5. Save changes
6. ZAP
7. APPEND FROM tablename\_temp
8. USE
9. BROW (optional - to view PKs)
10. USE  
When connecting to the VFP table from Servoy, make Row Ident ‘row\_ident’ for the VFP PK column. That should fix things for you.

---

<div class="post-metadata">

**Author:** ![deezzub](https://avatars.discourse-cdn.com/v4/letter/d/dec6dc/32.png) [@deezzub](https://forum.servoy.com/u/deezzub)\
**Post date:** [August 28, 2013, 2:02pm UTC](https://forum.servoy.com/t/error-says-table-has-no-primary-key-but-primary-key-exists/17396/6 "2013-08-28T14:02:07Z")

</div>

> kwpsd:  
> For Servoy to connect to VFP .DBF tables, the .DBF tables themselves must contain a PK column:
> 
> 1. USE tablename
> 2. COPY TO tablename\_temp
> 3. MODI STRU
> 4. Column name: PK, Type: Autoinc(Integer)
> 5. Save changes
> 6. ZAP
> 7. APPEND FROM tablename\_temp
> 8. USE
> 9. BROW (optional - to view PKs)
> 10. USE  
> When connecting to the VFP table from Servoy, make Row Ident ‘row\_ident’ for the VFP PK column. That should fix things for you.

After your suggestion, I get the following error on saving.:

```auto
save failed for 1 or more records
 > com.servoy.j2db.dataprocessing.DataException: java.lang.ClassCastException: com.hxtt.sql.common.c cannot be cast to [I
	at com.hxtt.sql.dbf.j.a(Unknown Source)
	at com.hxtt.sql.c9.do(Unknown Source)
	at com.hxtt.sql.fg.int(Unknown Source)
	at com.hxtt.sql.d2.a(Unknown Source)
	at com.hxtt.sql.bz.a(Unknown Source)
	at com.hxtt.sql.bz.a(Unknown Source)
	at com.hxtt.sql.bz.a(Unknown Source)
	at com.hxtt.sql.am.a(Unknown Source)
	at com.hxtt.sql.d4.executeUpdate(Unknown Source)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
	at java.lang.reflect.Method.invoke(Unknown Source)
	at com.servoy.j2db.datasource.Zg.invoke(Zg.java:2)
	at com.sun.proxy.$Proxy22.executeUpdate(Unknown Source)
	at org.apache.commons.dbcp.DelegatingPreparedStatement.executeUpdate(DelegatingPreparedStatement.java:105)
	at org.apache.commons.dbcp.DelegatingPreparedStatement.executeUpdate(DelegatingPreparedStatement.java:105)
	at org.apache.commons.dbcp.DelegatingPreparedStatement.executeUpdate(DelegatingPreparedStatement.java:105)
	at org.apache.commons.dbcp.DelegatingPreparedStatement.executeUpdate(DelegatingPreparedStatement.java:105)
	at com.servoy.j2db.dataprocessing.Zv.Za(Zv.java:523)
	at com.servoy.j2db.dataprocessing.Zv.performUpdates(Zv.java:591)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
	at java.lang.reflect.Method.invoke(Unknown Source)
	at com.servoy.j2db.util.AbstractRemoteInvocationHandler.invokeMethod(AbstractRemoteInvocationHandler.java:77)
	at com.servoy.j2db.util.ThreadingRemoteInvocationHandler$1.run(ThreadingRemoteInvocationHandler.java:79)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
	at java.lang.Thread.run(Unknown Source)

	at H:\servoy7_workspace\svy_nav_navigation\openEdits.js:38 (saveEditsFromObject)
	at H:\servoy7_workspace\svy_nav_navigation\forms\svy_nav_base.js:1423 (dc_save)
	at H:\servoy7_workspace\BOSS_Chartering\forms\boss_char_charterfaktura_base_dtl.js:1522 (dc_save)
	at H:\servoy7_workspace\svy_nav_navigation\forms\svy_nav_fr_toolbar_base.js:361 (callProgramFunction)

save failed for 1 or more records
 > com.servoy.j2db.persistence.RepositoryException: java.sql.SQLException: must rollback must rollback
	at H:\servoy7_workspace\svy_nav_navigation\openEdits.js:38 (saveEditsFromObject)
	at H:\servoy7_workspace\svy_nav_navigation\forms\svy_nav_base.js:1423 (dc_save)
	at H:\servoy7_workspace\BOSS_Chartering\forms\boss_char_charterfaktura_base_dtl.js:1522 (dc_save)
	at H:\servoy7_workspace\svy_nav_navigation\forms\svy_nav_fr_toolbar_base.js:361 (callProgramFunction)

com.servoy.j2db.dataprocessing.DataException: java.lang.ClassCastException: com.hxtt.sql.common.c cannot be cast to [I
	at com.hxtt.sql.dbf.j.a(Unknown Source)
	at com.hxtt.sql.c9.do(Unknown Source)
	at com.hxtt.sql.fg.int(Unknown Source)
	at com.hxtt.sql.d2.a(Unknown Source)
	at com.hxtt.sql.bz.a(Unknown Source)
	at com.hxtt.sql.bz.a(Unknown Source)
	at com.hxtt.sql.bz.a(Unknown Source)
	at com.hxtt.sql.am.a(Unknown Source)
	at com.hxtt.sql.d4.executeUpdate(Unknown Source)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
	at java.lang.reflect.Method.invoke(Unknown Source)
	at com.servoy.j2db.datasource.Zg.invoke(Zg.java:2)
	at com.sun.proxy.$Proxy22.executeUpdate(Unknown Source)
	at org.apache.commons.dbcp.DelegatingPreparedStatement.executeUpdate(DelegatingPreparedStatement.java:105)
	at org.apache.commons.dbcp.DelegatingPreparedStatement.executeUpdate(DelegatingPreparedStatement.java:105)
	at org.apache.commons.dbcp.DelegatingPreparedStatement.executeUpdate(DelegatingPreparedStatement.java:105)
	at org.apache.commons.dbcp.DelegatingPreparedStatement.executeUpdate(DelegatingPreparedStatement.java:105)
	at com.servoy.j2db.dataprocessing.Zv.Za(Zv.java:523)
	at com.servoy.j2db.dataprocessing.Zv.performUpdates(Zv.java:591)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
	at java.lang.reflect.Method.invoke(Unknown Source)
	at com.servoy.j2db.util.AbstractRemoteInvocationHandler.invokeMethod(AbstractRemoteInvocationHandler.java:77)
	at com.servoy.j2db.util.ThreadingRemoteInvocationHandler$1.run(ThreadingRemoteInvocationHandler.java:79)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
	at java.lang.Thread.run(Unknown Source)

	at com.servoy.j2db.dblayer.Zb.Za(Zb.java:194)
	at com.servoy.j2db.server.Za.Zo.Za(Zo.java:1521)
	at com.servoy.j2db.dataprocessing.Zv.Za(Zv.java:1199)
	at com.servoy.j2db.dataprocessing.Zv.performUpdates(Zv.java:591)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
	at java.lang.reflect.Method.invoke(Unknown Source)
	at com.servoy.j2db.util.AbstractRemoteInvocationHandler.invokeMethod(AbstractRemoteInvocationHandler.java:77)
	at com.servoy.j2db.util.ThreadingRemoteInvocationHandler$1.run(ThreadingRemoteInvocationHandler.java:79)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
	at java.lang.Thread.run(Unknown Source)

com.servoy.j2db.persistence.RepositoryException: java.sql.SQLException: must rollback must rollback
	at com.servoy.j2db.dataprocessing.Zv.Za(Zv.java:55)
	at com.servoy.j2db.dataprocessing.Zv.performUpdates(Zv.java:591)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
	at java.lang.reflect.Method.invoke(Unknown Source)
	at com.servoy.j2db.util.AbstractRemoteInvocationHandler.invokeMethod(AbstractRemoteInvocationHandler.java:77)
	at com.servoy.j2db.util.ThreadingRemoteInvocationHandler$1.run(ThreadingRemoteInvocationHandler.java:79)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
	at java.lang.Thread.run(Unknown Source)

```

[attachment=0]2013-08-28 15\_55\_04-Fehler\_beim\_Speichern.png[/attachment]

 ![2013-08-28 15_55_04-Fehler_beim_Speichern.png](https://canada1.discourse-cdn.com/flex010/uploads/servoy/original/1X/0461438a476eaaf6dcfb23d65da962c14be3c3d6.png)

---

<div class="post-metadata">

**Author:** ![kwpsd](https://avatars.discourse-cdn.com/v4/letter/k/bb73d2/32.png) [@kwpsd](https://forum.servoy.com/u/kwpsd)\
**Post date:** [August 29, 2013, 5:48pm UTC](https://forum.servoy.com/t/error-says-table-has-no-primary-key-but-primary-key-exists/17396/7 "2013-08-29T17:48:44Z")

</div>

Well, it looks like you got past the PK issue! ![:wink:]( "Wink")

> > com.servoy.j2db.dataprocessing.DataException: java.lang.ClassCastException: com.hxtt.sql.common.c cannot be cast to [I

It appears that the error message was truncated, so it is difficult to know exactly why the HXTT driver is complaining. However, I suspect that you are supplying a value that the HXTT driver is attempting to convert to an Integer (the truncated ‘I’ in the error message) in order to match the table column type. Recheck the supplied value types against the table column types.

---

<div class="post-metadata">

**Author:** ![deezzub](https://avatars.discourse-cdn.com/v4/letter/d/dec6dc/32.png) [@deezzub](https://forum.servoy.com/u/deezzub)\
**Post date:** [October 8, 2013, 1:58pm UTC](https://forum.servoy.com/t/error-says-table-has-no-primary-key-but-primary-key-exists/17396/8 "2013-10-08T13:58:02Z")

</div>

Today I got a message, see subject, but for a SQL table which has a “Row Ident” pk for the “servoy\_se” column. So I changed another columns “Row Ident” to row\_ident and saved the change. After that I reverted the columns “Row Ident” to nothing like before and saved. Now the error messages are gone.

So this error is maybe not related to any special database?

---

<div class="post-metadata">

**Author:** ![deezzub](https://avatars.discourse-cdn.com/v4/letter/d/dec6dc/32.png) [@deezzub](https://forum.servoy.com/u/deezzub)\
**Post date:** [October 11, 2013, 11:00am UTC](https://forum.servoy.com/t/error-says-table-has-no-primary-key-but-primary-key-exists/17396/9 "2013-10-11T11:00:22Z")

</div>

[Bug: SVY-5217](https://support.servoy.com/browse/SVY-5217).

---

<div class="post-metadata">

**Author:** ![ROCLASI](https://yyz2.discourse-cdn.com/flex010/user_avatar/forum.servoy.com/roclasi/32/4371_2.png) [@ROCLASI](https://forum.servoy.com/u/ROCLASI)\
**Post date:** [October 11, 2013, 11:06am UTC](https://forum.servoy.com/t/error-says-table-has-no-primary-key-but-primary-key-exists/17396/10 "2013-10-11T11:06:20Z")

</div>

> deezzub:  
> [Bug: SVY-5217](https://support.servoy.com/browse/SVY-5217) is fixed in Servoy 7.4

Actually how this works is that the fix version is the _planned_ version to fix it in.  
It is not certain until the issue is actually closed/fixed. SVY-5217 is still unresolved at this time.

Hope this explains things better.

---

<div class="post-metadata">

**Author:** ![deezzub](https://avatars.discourse-cdn.com/v4/letter/d/dec6dc/32.png) [@deezzub](https://forum.servoy.com/u/deezzub)\
**Post date:** [October 11, 2013, 12:34pm UTC](https://forum.servoy.com/t/error-says-table-has-no-primary-key-but-primary-key-exists/17396/11 "2013-10-11T12:34:20Z")

</div>

> ROCLASI:
> 
> > deezzub:  
> > [Bug: SVY-5217](https://support.servoy.com/browse/SVY-5217) is fixed in Servoy 7.4
> 
> Actually how this works is that the fix version is the _planned_ version to fix it in.  
> It is not certain until the issue is actually closed/fixed. SVY-5217 is still unresolved at this time.
> 
> Hope this explains things better.

Sorry, you are right. I have read inaccurately. I change it. ![;)]( "Wink")
