• 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
  • Jeanne Boyarsky
  • Devaka Cooray
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Knute Snortum
  • Bear Bibeault
Saloon Keepers:
  • Ron McLeod
  • Tim Moores
  • Stephan van Hulst
  • Piet Souris
  • Ganesh Patekar
Bartenders:
  • Frits Walraven
  • Carey Brown
  • Tim Holloway

Creating tables from text file

 
Ranch Hand
Posts: 44
Netbeans IDE PHP Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello, ranchers!

I am trying to create multiple tables from a single textfile called "tables.sql". The tables are marked with a "+" and "|" sign as a delimeter after each
line. In a part of the code I replace the delimeters with the replace method in the String class with some empty space, "" and the "+" sign with a
new line character.

My tables are very basic for this post but longer in real world, they look similar to this in the text file "tables.sql".



Here is my java code for processing the file with the example tables but it doesn't work. I get the error message "You have an error in
your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near
'CREATE TABLE example2_tbl"



Why is this not working? I don't understand why jdbc can't create multiple tables in one query from a text file and what is needed for it to do so.
I think i must be missing something really obvious here. Any hint or enlightment in this matter is very much appreciated.
Thanks a lot in advance!

Regards,
Robert.





 
Saloon Keeper
Posts: 2613
329
Android Eclipse IDE Angular Framework MySQL Database TypeScript Redhat Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Robert Ingmarsson wrote:I don't understand why jdbc can't create multiple tables in one query ...


It's not JDBC - it's MySQL - probably a feature to combat SQL injection.

To disable the feature try setting the allowMultiQueries property to true:
    "jdbc:mysql://localhost:3306/test?allowMultiQueries=true"
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!