- Posted by: Joe Attardi
- Posted on: May 17 2004 00:10 EDT
I'm at my wit's end here. I'm trying to deploy my first CMP entity bean using JBoss and MySQL and I keep getting this error message when deploying the EJB jar:
Caused by: java.sql.SQLException: Syntax error or access violation, message fro
m server: "You have an error in your SQL syntax. Check the manual that correspo
nds to your MySQL server version for the right syntax to use near 'User (uid INT
EGER NOT NULL, fullname VARCHAR(250) BINARY NOT NU"
The definition for my CMP bean looks like (from jbosscmp-jdbc.xml):
Any idea what I'm doing wrong to make the SQL get messed up?
- CMP entity bean + JBoss + MySQL = error! Help! by Yoandy Rodriguez on May 17 2004 12:43 EDT
- Problem solved! by Joe Attardi on May 18 2004 09:19 EDT
As long as I can see there's nothing bad with your deployment descriptor, maybe you should look into your DataSources definitions.
As long as I can see there's nothing bad with your deployment descriptor, maybe you should look into your DataSources definitions.Hi Yoandy,
Thanks for your reply. I don't see how it could be my DataSource definition since it is talking to the MySQL server successfully. I will try to log the SQL statements so I can see the SQL the CMP is trying to execute, maybe we can see it more clearly then.
I have a similar problem, since I get a meaningless message from JBOSS (a syntax error near ) on the query) during the creation of table, can you explain how you log the query made by JBOSS on mysql.
I'm not sure how to do this in JBoss, but you can turn on logging in MySQL when you start the server: mysqld_safe --log. All statements will be logged to a file in the data directory.
For anyone who was interested, I found the problem. Actually there were two problems.
1) The name of the table I assigned to the CMP bean was 'user'. Apparently MySQL doesn't like that since it maintains a 'user' table in the 'mysql' database.
2) In my primary key class (I always make custom primary key classes even if the primary key is just a primitive type), the variable name of the field did not match the field name I specified in the jbosscmp-jdbc.xml file, so when it was creating the primary key constraint it wasn't passing any field name, so one of the parameters was blank. I fixed that and now my bean deployed no problem!