Search code examples
javamysqlspring-jdbcpaas

What could be the cause of Forbidden command : SHOW WARNINGS to MySql from SpringJDBC


Recently, I created a java app on an appengine Paas (name jd-app.com). But a very general SpringJDBC application wouldn't run because it shows exception for a simple query like "select * from user" for MySql. The files are from http://www.beingjavaguys.com

Very frustrated after a few days of trying so I am putting some code and configuration here hoping someone with knowledge or similar experience can help.

Code:

UserDaoImpl.java

public List<User> getUserList() {
    List<User> userList = new ArrayList<User>();
    String sql = "select * from user";
    userList = jdbcTemplate.query(sql, new UserRowMapper());

spring-servlet.xml

<bean id="dataSource"
    class="org.springframework.jdbc.datasource.DriverManagerDataSource">
    <property name="driverClassName" value="com.mysql.jdbc.Driver" />
    <property name="url" value="jdbc:mysql://10.0.16.16:4066/databasenamehidden" />
    <property name="username" value="xxxxx" />
    <property name="password" value="yyyyyy" />
</bean>

Exception:

HTTP Status 500 - Request processing failed; nested exception is org.springframework.jdbc.UncategorizedSQLException: StatementCallback; uncategorized SQLException for SQL [select * from wp_users]; SQL state [HY000]; error code [3013]; Forbidden command : SHOW WARNINGS; nested exception is java.sql.SQLException: Forbidden command : SHOW WARNINGS

Root cause

... org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:84) org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:81) org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:81) org.springframework.jdbc.core.JdbcTemplate.execute(JdbcTemplate.java:413) org.springframework.jdbc.core.JdbcTemplate.execute(JdbcTemplate.java:437) com.beingjavaguys.dao.UserDaoImpl.getUserList(UserDaoImpl.java:63)

Discussion

On the same Paas, I uploaded a Wordpress app which can access MySql and runs perfectly. But if I config that database in the spring-servlet.xml and select * from wp_users, then I will also see this exception from the SpringJDBC app.

I tried to change that sql query to other statement and I always get same exceptions. So what could be a reason for that? I can upload more code upon request.


Solution

  • As mentioned by Nikhil, the error is from a forbidden command, and that is SHOW WARNINGS.

    Maybe your Paas doesn't allow SHOW WARNINGS?