• 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Junilu Lacar
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Knute Snortum
  • Devaka Cooray
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Ron McLeod
  • Carey Brown
Bartenders:
  • Paweł Baczyński
  • Piet Souris
  • Vijitha Kumara

ORA-00923: FROM keyword not found where expected using UPSERT in PreparedStatement

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm setting up a PreparedStatement that will be used in regards to a Kafka Consumer. The program in it self runs addBatch() 500 times before running an executeBatch().

My problem is the following PreparedStatement (sorry about formatting):


When executeBatch() is executed, i get the following error message:


As far as I am concerned, the SQL querry looks correct, but obviously something is wrong here. In advance, thank you!
 
Rancher
Posts: 4315
47
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I recommend printing out that String, before passing it to the PreparedStatement.

It's a lot easier to find errors that way.
Like missing spaces (I can see one at the end of the second line of code there) which would result in elements being merged together.
In the case of the bit I can see, you end up with COLUMN9?, with no space.
Indeed, that one has missed its comma as well:
... ? COLUMN7, ? COLUMN8, ? COLUMN9? COLUMN10, ? COLUMN11, ...

There's a couple more instances further on as well.
 
Markus Løyte
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Dave Tolls wrote:I recommend printing out that String, before passing it to the PreparedStatement.

It's a lot easier to find errors that way.
Like missing spaces (I can see one at the end of the second line of code there) which would result in elements being merged together.
In the case of the bit I can see, you end up with COLUMN9?, with no space.
Indeed, that one has missed its comma as well:
... ? COLUMN7, ? COLUMN8, ? COLUMN9? COLUMN10, ? COLUMN11, ...

There's a couple more instances further on as well.



Yeah, I am sorry about that.
When editing the colum and table names, I accidently removed some spaces here and there. The OP should now reflect the actual text in the statement.
 
Dave Tolls
Rancher
Posts: 4315
47
  • Likes 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I still recommend actually printing out the query.
It's a lot easier to see issues.
And you can format the query nicely.
 
Markus Løyte
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Dave Tolls wrote:I still recommend actually printing out the query.
It's a lot easier to see issues.
And you can format the query nicely.



Thank you so much, turns out there were issues with a few commas missing...
It threw me off because of the error message refering to the 'FROM' keyword, but everything is good and works as intended now!
 
Sheriff
Posts: 6363
172
Eclipse IDE Postgres Database VI Editor Chrome Java Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Markus Løyte wrote:... The OP should now reflect the actual text in the statement.


It looks like you edited the original post.  Please don't do that.  Instead, post a reply with the modified code.  
 
The glass is neither half full or half empty. It is too big. But this tiny ad is just right:
Java file APIs (DOC, XLS, PDF, and many more)
https://products.aspose.com/total/java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!