Meaningless Drivel is fun!
The moose likes JDBC and Relational Databases and the fly likes JAVA Postgres insert Problem Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC and Relational Databases
Bookmark "JAVA Postgres insert Problem" Watch "JAVA Postgres insert Problem" New topic

JAVA Postgres insert Problem

Kamil Rak

Joined: Sep 11, 2012
Posts: 5
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.
Ulf Dittmer

Joined: Mar 22, 2005
Posts: 42958
What is "a problem" ? Surely Eclipse says more than that.
Kamil Rak

Joined: Sep 11, 2012
Posts: 5
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(
at org.postgresql.core.v3.QueryExecutorImpl.processResults(
at org.postgresql.core.v3.QueryExecutorImpl.execute(
at org.postgresql.jdbc2.AbstractJdbc2Statement.execute(
at org.postgresql.jdbc2.AbstractJdbc2Statement.executeWithFlags(
at org.postgresql.jdbc2.AbstractJdbc2Statement.execute(
at bazaDanych.KlientDB.insert(
at bazaDanych.Testowa.main(
Jeanne Boyarsky
author & internet detective

Joined: May 26, 2003
Posts: 32614

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?

[OCA 8 book] [Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Other Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, TOGAF part 1 and part 2
Kamil Rak

Joined: Sep 11, 2012
Posts: 5
You are right...
I tried different options and found out the right one. It should be nextval('idklienta_seq ') so the try block is:


Thanks for help!
I agree. Here's the link:
subject: JAVA Postgres insert Problem
It's not a secret anymore!