Apache Roller
  1. Apache Roller
  2. ROL-634

Invalid SQL Syntax Exception at context setup

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Won't Fix
    • Affects Version/s: 1.0.0
    • Fix Version/s: None
    • Labels:
      None
    • Environment:
      Windows XP SP1
      J2SE 1.4.2_05
      Tomcat 5.0.28
      MySQL 4.19-nt
      mysql-connector-java-3.1.6-bin.jar
    • Browser Version:
      Firefox 1.0
    • Database:
      MySQL 4.19-nt
    • JDK Version:
      Sun JDK 1.4.2_05
    • O/S Version:
      Windows XP SP1

      Description

      I get the following exception whenever I start tomcat

      ERROR 2005-01-20 17:34:51,810 | JDBCException:<init> | SQLException occurred
      java.sql.SQLException: You have an error in your SQL syntax; check the manual th
      at corresponds to your MySQL server version for the right syntax to use near '?'
      at line 1
      at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:2851)
      at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1534)
      at com.mysql.jdbc.ServerPreparedStatement.serverPrepare(ServerPreparedSt
      atement.java:1485)
      at com.mysql.jdbc.ServerPreparedStatement.<init>(ServerPreparedStatement
      .java:151)
      at com.mysql.jdbc.Connection.prepareStatement(Connection.java:1309)
      at com.mysql.jdbc.Connection.prepareStatement(Connection.java:1281)
      at org.apache.commons.dbcp.DelegatingConnection.prepareStatement(Delegat
      ingConnection.java:185)
      at org.apache.commons.dbcp.PoolingDataSource$PoolGuardConnectionWrapper.
      prepareStatement(PoolingDataSource.java:278)
      at net.sf.hibernate.impl.BatcherImpl.getPreparedStatement(BatcherImpl.ja
      va:249)
      at net.sf.hibernate.impl.BatcherImpl.getPreparedStatement(BatcherImpl.ja
      va:223)
      at net.sf.hibernate.impl.BatcherImpl.prepareQueryStatement(BatcherImpl.j
      ava:65)
      at net.sf.hibernate.loader.Loader.prepareQueryStatement(Loader.java:704)

      at net.sf.hibernate.loader.Loader.doQuery(Loader.java:185)
      at net.sf.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections
      (Loader.java:133)
      at net.sf.hibernate.loader.Loader.doList(Loader.java:955)
      at net.sf.hibernate.loader.Loader.list(Loader.java:946)
      at net.sf.hibernate.loader.CriteriaLoader.list(CriteriaLoader.java:121)
      at net.sf.hibernate.impl.SessionImpl.find(SessionImpl.java:3609)
      at net.sf.hibernate.impl.CriteriaImpl.list(CriteriaImpl.java:238)
      at org.roller.business.hibernate.HibernateConfigManagerImpl.getRollerCon
      fig(HibernateConfigManagerImpl.java:46)
      at org.roller.presentation.RollerContext.setupRollerConfig(RollerContext
      .java:502)
      at org.roller.presentation.RollerContext.contextInitialized(RollerContex
      t.java:158)
      at org.apache.catalina.core.StandardContext.listenerStart(StandardContex
      t.java:3827)

      I verified the jdbc URLs configured in the Roller <Context> element by using them in my own program. The user and password are specified correctly so I am at a loss.

      Any help on the matter will be greatly appreciated

        Activity

        Hide
        Joel Grenon added a comment -

        Got the same problem. After debugging, found that the problem is with the setMaxResult(1) from Hibernate. It adds a limit ? statement to the query which seems to cause the syntax error. Just comment this line and recompile Roller.
        File : org.roller.business.hibernate.HibernateConfigManagerImpl.java

        --------- BEGIN CODE -----------
        public RollerConfigData getRollerConfig() throws RollerException
        {
        try

        { Session session = ((HibernateStrategy)mStrategy).getSession(); Criteria criteria = session.createCriteria(RollerConfigData.class); // criteria.setMaxResults(1); List list = criteria.list(); return list.size()!=0 ? (RollerConfigData)list.get(0) : null; }

        catch (HibernateException e)

        { throw new RollerException(e); }

        }
        --------- END CODE -----------

        Show
        Joel Grenon added a comment - Got the same problem. After debugging, found that the problem is with the setMaxResult(1) from Hibernate. It adds a limit ? statement to the query which seems to cause the syntax error. Just comment this line and recompile Roller. File : org.roller.business.hibernate.HibernateConfigManagerImpl.java --------- BEGIN CODE ----------- public RollerConfigData getRollerConfig() throws RollerException { try { Session session = ((HibernateStrategy)mStrategy).getSession(); Criteria criteria = session.createCriteria(RollerConfigData.class); // criteria.setMaxResults(1); List list = criteria.list(); return list.size()!=0 ? (RollerConfigData)list.get(0) : null; } catch (HibernateException e) { throw new RollerException(e); } } --------- END CODE -----------
        Hide
        Anil Gangolli added a comment -

        Not a roller bug. This is due to a MySQL bug in the 3.1.X Connector/J drivers when talking to 4.1.X servers.

        See the InstallationFAQs # 13 for proper workarounds.

        http://www.rollerweblogger.org/wiki/Wiki.jsp?page=InstallationFAQs#ref-InstallationFAQs-13

        It includes a link there to the reported MySQL bug.

        Show
        Anil Gangolli added a comment - Not a roller bug. This is due to a MySQL bug in the 3.1.X Connector/J drivers when talking to 4.1.X servers. See the InstallationFAQs # 13 for proper workarounds. http://www.rollerweblogger.org/wiki/Wiki.jsp?page=InstallationFAQs#ref-InstallationFAQs-13 It includes a link there to the reported MySQL bug.
        Hide
        Anil Gangolli added a comment -

        At least two other users on the roller-user mailing list have reported the same issue and reported success using the suggested resolutions from the FAQ to workaround the MySQL bug. I'm closing this, for now, but please reopen with comments if you feel it appropriate.

        Show
        Anil Gangolli added a comment - At least two other users on the roller-user mailing list have reported the same issue and reported success using the suggested resolutions from the FAQ to workaround the MySQL bug. I'm closing this, for now, but please reopen with comments if you feel it appropriate.

          People

          • Assignee:
            Anil Gangolli
            Reporter:
            Stefano Santoro
          • Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development