Win a copy of Mastering Non-Functional Requirements this week in the Design forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Problems with creating table in mysql through JSP  RSS feed

 
hso xu
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi i am trying to create a table in mysql database through jsp.
i am using jsp to upload the *.sql files into my server, and at the same time i want the mysql to import the *.sql. Unfortunately in order for my to open the sql file i need to use the commend \. *.sql but when i use this command in jsp, i get an error:
illegal escape character
updateDatabase= "\. "+fileName+"";
^
wat should i do?
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The back slash is an escape character in Java.
You will need to escape that:

String sqlcommand = "\\. filename.sql";
 
hso xu
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
ok i get this error now
java.sql.SQLException: 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 '\. addresses.sql' at line 1
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm not a mySql guru but I believe the backslash commands are particular to the mysql command line interface. I don't think they can be called like the rest of the SQL commands via JDBC.

This topic might do better in the JDBC forum.
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65961
139
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Moved to the JDBC forum.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!