Getting a "MySQLSyntaxErrorException" on deploy
brandx Oct 12, 2010 5:53 PMThe specific error, when I deploy my WAR is:
Caused by: com.mysql.jdbc.exceptions.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
The small black square made me think that the issue was some sort of encoding issue, so I tried setting the MySQL schema to ASCII. It didn't change anything. Here's the details of my entire project:
- Packages ---
jboss 5.1.0 GA
MySQL 5.1.51
JDK 1.5.0 R22
MySQL Connector/J 5.1.13
- mysql-ds.xml ---
<datasources>
<local-tx-datasource>
<jndi-name>MySqlDS</jndi-name>
<connection-url>jdbc:mysql://localhost:3306/jboss</connection-url>
<driver-class>com.mysql.jdbc.Driver</driver-class>
<user-name>jbossuser</user-name>
<password>jbosspass</password>
<min-pool-size>5</min-pool-size>
<!-- Don't set this any higher than max_connections on your
MySQL server, usually this should be a 10 or a few 10's
of connections, not hundreds or thousands -->
<max-pool-size>20</max-pool-size>
<!-- Don't allow connections to hang out idle too long,
never longer than what wait_timeout is set to on the
server...A few minutes is usually okay here,
it depends on your application
and how much spikey load it will see -->
<idle-timeout-minutes>5</idle-timeout-minutes>
<!-- If you're using Connector/J 3.1.8 or newer, you can use
our implementation of these to increase the robustness
of the connection pool. -->
<exception-sorter-class-name>com.mysql.jdbc.integration.jboss.ExtendedMysqlExceptionSorter</exception-sorter-class-name>
<valid-connection-checker-class-name>com.mysql.jdbc.integration.jboss.MysqlValidConnectionChecker</valid-connection-checker-class-name>
<!-- corresponding type-mapping in the standardjbosscmp-jdbc.xml (optional) -->
<metadata>
<type-mapping>mySQL</type-mapping>
</metadata>
</local-tx-datasource>
</datasources>
- persistence.xml ---
<persistence
xmlns="http://java.sun.com/xml/ns/persistence"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd"
version="1.0"
>
<persistence-unit name="RPersist">
<jta-data-source>java:/MySqlDS</jta-data-source>
<properties>
<property name="javax.persistence.jdbc.driver" value="com.mysql.jdbc.Driver" />
<property name="javax.persistence.jdbc.url" value="jdbc:mysql://localhost:3306/jboss" />
<property name="javax.persistence.jdbc.user" value="jbossuser" />
<property name="javax.persistence.jdbc.password" value="jbosspass" />
<!-- JBoss Specific? -->
<property name="hibernate.connection.driver_class" value="com.mysql.jdbc.Driver"/>
<property name="hibernate.connection.url" value="jdbc:mysql://localhost:3306/jboss"/>
<property name="hibernate.connection.username" value="jbossuser"/>
<property name="hibernate.connection.password" value="jbosspass"/>
<property name="hibernate.connection.password" value="jbosspass"/>
<property name="hibernate.dialect" value="org.hibernate.dialect.MySQLInnoDBDialect"/>
<property name="hibernate.connection.datasource" value="java:/MySqlDS" />
<property name="hibernate.c3p0.min_size" value="5"/>
<property name="hibernate.c3p0.max_size" value="20"/>
<property name="hibernate.c3p0.timeout" value="300"/>
<property name="hibernate.c3p0.max_statements" value="50"/>
<property name="hibernate.c3p0.idle_test_period" value="3000"/>
</properties>
</persistence-unit>
</persistence>
- IRObject.java ---
import javax.ejb.*;
@Local
interface IRObject {
public boolean login(String uname);
}
- RObject.java ---
import javax.persistence.*;
import javax.ejb.*;
@Stateful
public class RObject implements IRObject {
@PersistenceContext(unitName="RPersist",type=PersistenceContextType.EXTENDED)
private EntityManager em;
@Init
public void onInit() {
}
public boolean login(String uname) {
return true;
}
}