Win a copy of Java XML & JSON this week in the XML and Related Technologies 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
  • Devaka Cooray
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Junilu Lacar
  • Paul Clapham
  • Knute Snortum
Saloon Keepers:
  • Ron McLeod
  • Tim Moores
  • Stephan van Hulst
  • salvin francis
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Frits Walraven
  • Ganesh Patekar

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: 2329
293
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"
 
I have gone to look for myself. If I should return before I get back, keep me here with this tiny ad:
Programmatically Create PDF Using Free Spire.PDF with Java
https://coderanch.com/wiki/703735/Programmatically-Create-PDF-Free-Spire
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!