Win a copy of OCP Oracle Certified Professional Java SE 11 Programmer I Study Guide: Exam 1Z0-815 this week in the Programmer Certification forum!
  • 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

Strange column error in table

 
Ranch Hand
Posts: 86
1
Netbeans IDE PHP Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, y'all!

I am recoding an old media manager application of mine and have encountered a strange behvaior in an insert into-event.
My table in question is stored in a text file consisting of ";"-delimited fields, so far it's a very small table,
but will be much bigger in the future, but for now I have encountered this column-error that is driving me crazy. For now,
my table look like this in it's text file:



I read in the text file with the following method



In a class called MediaTitleRecord i insert values into the column fields using a PreparedStatement like below:



But this operation results in the following error that is printed out to the console:



I am sorry if I have posted too much code here, but I have tried to keep it down to a small amount. Could anyone
help me to try to figure out what is going on here? Why is my program having trouble with the column ORIG_TITLE in the
TBL_MEDIATITLE - table?

Best regards,
Robert!


 
Sheriff
Posts: 6374
172
Eclipse IDE Postgres Database VI Editor Chrome Java Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Have you checked the table your text file created?  Does it look correct?  In your table creating code, you could print the data variable before you execute it.  I suspect data has places that it needs spaces.  I would replace the ";" with a space, not an empty string. Also, I think the split is unnecessary.

 
Robert Ingmarsson
Ranch Hand
Posts: 86
1
Netbeans IDE PHP Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Knute Snortum wrote:Have you checked the table your text file created?  Does it look correct?  In your table creating code, you could print the data variable before you execute it.  I suspect data has places that it needs spaces.  I would replace the ";" with a space, not an empty string. Also, I think the split is unnecessary.



Best, Mr Snortum!

Thank you so much for the reply. Would you be so kind and show me an example of code that describe the problem in question. I have tried the table creating code without a split but I don't wan't the table structure consist of one single line in the text file so thats why I am using a split. I am a little confused. Sorry. Which data variable do you refer to?

Regards,
Robert!
 
Knute Snortum
Sheriff
Posts: 6374
172
Eclipse IDE Postgres Database VI Editor Chrome Java Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I believe this is all you need:
 
Robert Ingmarsson
Ranch Hand
Posts: 86
1
Netbeans IDE PHP Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Knute Snortum wrote:I believe this is all you need:



Best, Mr. Snortum!

I changed the code in my openFile(Connection conn, String fileName) method and applied the code after your example
so now the method in question looks like this



And when i now insert a record in the table tbl_mediatitle in the class MediaTitleRecord that extends a thread object (as showned above in this post) everything seems to work fine!! Was this a space error in the table creating method? I think it was that. Thank you so much for your kind reply it saved me from a lot of headaches. I believe this subject has come to a close now, thank you so much again.


Best regards,
Robert!  






 
Knute Snortum
Sheriff
Posts: 6374
172
Eclipse IDE Postgres Database VI Editor Chrome Java Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Was this a space error in the table creating method?


If I understand you correctly, yes.  You were trimming off the spaces so the lines would bump up against each other.
 
Robert Ingmarsson
Ranch Hand
Posts: 86
1
Netbeans IDE PHP Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Best, Mr. Snortum!

Again, thanks a lot and yes you understood me exactly right.

Best wishes,
Robert!
 
It's just a flesh wound! Or a tiny ad:
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!