• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Jeanne Boyarsky
  • Ron McLeod
Sheriffs:
  • Paul Clapham
  • Liutauras Vilda
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

Problem with trying to Insert values into User

 
Ranch Hand
Posts: 231
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Created a SQL script, InsertUser.sql, on MySQL 5...



This is the error I receive:


/* MySQL 01:00:12 */ 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 ''id', 'emailAddress', 'lastAccessTime', 'login_name', '
password', 'registrationD' at line 3;


Any help is most appreciated...
 
Marshal
Posts: 80273
430
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Have you missed out VALUES?
 
James Dekker
Ranch Hand
Posts: 231
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I don't understand your question... I am MySQL n00b (very sorry to say)...

Copied this script word to word, symbol by symbol out of book...

Don't you see the VALUES declaration?

Thanks for the response...
 
Campbell Ritchie
Marshal
Posts: 80273
430
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You have got VALUES in. Sorry. I looked in the wrong place. Try removing all the quote marks in the () after "into user" and before "VALUES".
 
author and cow tipper
Posts: 5009
1
Hibernate Spring Tomcat Server
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
That's, like, on page 196 of my book Hibernate Made Easy! My assumption is that most people that buy my technical books rarely get past the first chapter. I'm not sure if anyone has ever read that far?

I'm wondering if the formatting for the book may be chocking MySQL. Maybe the carriage return added after or before 'VALUES' throws off the editor?

I just saw the message, so I'll be testing it.

Heh...

(1,'[email protected]','2008-01-13 14:49:01','mj','abc123','2006-02-01', 0x00),



That was written over a year ago, but still topical today. Michael Jackson never gets old.

-Cameron McKenzie
 
Cameron Wallace McKenzie
author and cow tipper
Posts: 5009
1
Hibernate Spring Tomcat Server
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
So, that SQL was what Hibernate output to the console after running the Java code given for creating Users. It looks like you need to strip a few single quotes out of there to get it to run in the MySQL editor. Here's a single line that can be put into the MySQL query window and work as is:



The carriage returns have no harming effect. Notice the first brackets () have no single quotes around id, emailAddress, etc. I also preceeded User with examscam, and took the quotes off of user. Some databases need quotes around user as it is a reserved word for most databases.

Here's the full code I used in the MySQL query browser to get things working:



The option used in the book was to just type the following into your Java editor and run it, which is the approach I'm assuming most people used. I updated the errata page on my website:





Hibernate Made Easy Book Errata

And here's the source code if anyone is looking for it:

Source code from the book Hibernate Made Easy

Thanks for the Monday Morning assignment!

-Cameron McKenzie

 
And then the flying monkeys attacked. My only defense was this tiny ad:
Smokeless wood heat with a rocket mass heater
https://woodheat.net
reply
    Bookmark Topic Watch Topic
  • New Topic