• 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

Com.mysql.jdbc.MySQLSyntaxErrorException: Table 'comments.politics_news' doesn't exist.

 
Ranch Hand
Posts: 47
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
With the amount of information online about this error I bet anyone who's solved this issue on a platter of gold would say i didn't do enough research. But I did. I've dropped my database, create another in an attempt to solve this error but no it didn't work. When I create another table in 'comments' and inserted data into it it worked perfectly but when I try to insert into 'politics_news' after creating it In my java program i get this error. I get the same error when I try to insert through database client also.

Here's the block of code that throws the error:
 
Victor Ade
Ranch Hand
Posts: 47
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Victor Ade wrote:With the amount of information online about this error I bet anyone who's solved this issue on a platter of gold would say i didn't do enough research. But I did. I've dropped my database, create another in an attempt to solve this error but no it didn't work. When I create another table in 'comments' and inserted data into it it worked perfectly but when I try to insert into 'politics_news' after creating it In my java program i get this error. I get the same error when I try to insert through database client also.

Here's the block of code that throws the error:



ERROR FREE VERSION


With the amount of information online about this error I bet anyone who's solved this issue on a platter of gold would say i didn't do enough research. But I did. I've dropped my database, create another in an attempt to solve this error but no it didn't work. When I create another table in 'comments' and inserted data into it it worked perfectly but when I try to insert into 'politics_news' after creating it In my java program i get this error. I get the same error when I try to insert through database client also.

Here's the block of code that throws the error:




 
Rancher
Posts: 4801
50
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Build your table creation String as a separate object and print it out.
Looks to me like there aren't enough spaces in there.
It would also help ensure the table name is valid.

Do you have an catch blocks for checking SQLExceptions?  I would have expected the CREATE TABLE to throw an error.

Also, I think that should be an executeUpdate?  Can't guarantee that part, though.
 
Sheriff
Posts: 7125
184
Eclipse IDE Postgres Database VI Editor Chrome Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Don't you need a space right after TABLE?
 
Marshal
Posts: 28177
95
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
This code:



Won't compile. But assuming you wanted to use the setString() method, like this:



You still have a problem, namely that you never set the second and third parameters of the PreparedStatement. You should get an exception thrown in that case too -- is it possible that you have a catch block which ignores exceptions? In both cases, this one and the one where your Create Table statement is missing whitespace, you should have got an exception which described the problem for you.

 
Victor Ade
Ranch Hand
Posts: 47
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Knute Snortum wrote:
Don't you need a space right after TABLE?



you are king knute. this is where the problem lies.
 
Knute Snortum
Sheriff
Posts: 7125
184
Eclipse IDE Postgres Database VI Editor Chrome Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks.  Dave Tolls mentioned it too.
 
Dave Tolls
Rancher
Posts: 4801
50
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Victor Ade wrote:

you are king knute. this is where the problem lies.



Which should have resulted in a SQLException.
The fact that it didn't implies that you are either ignoring exceptions (empty catch blocks) or you are not logging them properly (printing the stack trace and message).

That's a bug that needs fixing, as it would have saved you a lot of time.
 
reply
    Bookmark Topic Watch Topic
  • New Topic