Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

creating db and table in java

 
paul beppe
Ranch Hand
Posts: 86
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
for create db in java i write this code:


and it's ok!!

for create table i have problems..this is code:


i have this error:
Database created !
com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: 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 '' at line 1

help!!
 
Paul Clapham
Sheriff
Posts: 21583
33
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
When the error message says that you have a syntax error in your SQL, then what you should do is to look at your SQL and see what's wrong with it. That should be fairly obvious, no? So why not put in a debugging statement which outputs the SQL to the console so you can see it (and not just some Java code which builds it)?
 
Swaroop Kondeddy
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Your table string should be like this

 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic