• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

JAVA Postgres insert Problem

 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi there,

I am writing a database app in java and do hava a problem with inserting a value into the table.

So here it is: I have created the database in postgres and made a table named "klient"
There is a column named id_klienta which is an autoincremented primery key (there is also a sequence called idklienta_seq that is responsible for autoincrementation).

When I try to start the insert method I got the Exception:
missing from-clause for table "idklienta"

Here is the Java code:




---------------------------------------------------



--------------------------------------------------------------------


Eclipse says there is a problem in the
pst.execute(); - KlientDB class.
If you could help me to fix that problem that would bu really great.
 
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What is "a problem" ? Surely Eclipse says more than that.
 
Kamil Rak
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Sorry,
I simpy forgot about it...
Here the console output:

org.postgresql.util.PSQLException: ERROR: missing from-clause for table "idklienta"
Pozycja: 121
at org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:2101)
at org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:1834)
at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:255)
at org.postgresql.jdbc2.AbstractJdbc2Statement.execute(AbstractJdbc2Statement.java:510)
at org.postgresql.jdbc2.AbstractJdbc2Statement.executeWithFlags(AbstractJdbc2Statement.java:386)
at org.postgresql.jdbc2.AbstractJdbc2Statement.execute(AbstractJdbc2Statement.java:379)
at bazaDanych.KlientDB.insert(KlientDB.java:153)
at bazaDanych.Testowa.main(Testowa.java:50)
 
author & internet detective
Posts: 41860
908
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Welcome to CodeRanch! I added code tags to make the code easier to read.

I've never seen this syntax before in postgres:


Are you sure it is right? Do you have an example you got it from?
 
Kamil Rak
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You are right...
I tried different options and found out the right one. It should be nextval('idklienta_seq ') so the try block is:



and



Thanks for help!
 
reply
    Bookmark Topic Watch Topic
  • New Topic