This week's book giveaway is in the Spring forum.
We're giving away four copies of Spring in Action (5th edition) and have Craig Walls on-line!
See this thread for details.
Win a copy of Spring in Action (5th edition) this week in the Spring 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
  • Bear Bibeault
  • Devaka Cooray
  • Liutauras Vilda
  • Jeanne Boyarsky
Sheriffs:
  • Knute Snortum
  • Junilu Lacar
  • paul wheaton
Saloon Keepers:
  • Ganesh Patekar
  • Frits Walraven
  • Tim Moores
  • Ron McLeod
  • Carey Brown
Bartenders:
  • Stephan van Hulst
  • salvin francis
  • Tim Holloway

Creating tables from text file  RSS feed

 
Ranch Hand
Posts: 36
Java Netbeans IDE PHP
  • 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: 2150
278
Android Angular Framework Eclipse IDE Java Linux MySQL Database Redhat TypeScript
  • 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"
 
Die Fledermaus does not fear such a tiny ad:
Download Free Java APIs to Work with Office Files and PDF
htttp://www.e-iceblue.com/free-apis.html
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!