2 Replies Latest reply on Jul 19, 2011 7:06 PM by 822327

    SQL syntax exception: missing expression?

    822327
      I got following exception while executing:

      public HolidayDAO locateByDate (String locale, Date date) {
      .........
      String queryString = "select o from HolidayDAO o where o.locale = '" + locale + "' and o.date = :date";
      Query selectQuery = em.createQuery(queryString);
      selectQuery.setParameter("date", date, TemporalType.DATE);
      ...........
      }

      I have the following declared in HolidayDAO class:

      @Column(name="DATE")
      @Temporal(TemporalType.DATE)
      private Date date;



      Exception [EclipseLink-4002] (Eclipse Persistence Services - 2.3.0.v20110604-r9504): org.eclipse.persistence.exceptions.DatabaseException
      Internal Exception: java.sql.SQLSyntaxErrorException: ORA-00936: missing expression

      Error Code: 936
      Call: SELECT HOLIDAY_ID, DATE, LOCALE, YEAR FROM ORA47111.S_HOLIDAY WHERE ((LOCALE = ?) AND (DATE = ?))
           bind => [2 parameters bound]
      Query: ReadAllQuery(referenceClass=HolidayDAO sql="SELECT HOLIDAY_ID, DATE, LOCALE, YEAR FROM ORA47111.S_HOLIDAY WHERE ((LOCALE = ?) AND (DATE = ?))")
           at org.eclipse.persistence.exceptions.DatabaseException.sqlException(DatabaseException.java:333)
           at org.eclipse.persistence.internal.databaseaccess.DatabaseAccessor.basicExecuteCall(DatabaseAccessor.java:644)
           at org.eclipse.persistence.internal.databaseaccess.DatabaseAccessor.executeCall(DatabaseAccessor.java:535)
           at org.eclipse.persistence.internal.sessions.AbstractSession.basicExecuteCall(AbstractSession.java:1702)
           at org.eclipse.persistence.sessions.server.ServerSession.executeCall(ServerSession.java:566)
           at org.eclipse.persistence.internal.queries.DatasourceCallQueryMechanism.executeCall(DatasourceCallQueryMechanism.java:207)
           at org.eclipse.persistence.internal.queries.DatasourceCallQueryMechanism.executeCall(DatasourceCallQueryMechanism.java:193)
           at org.eclipse.persistence.internal.queries.DatasourceCallQueryMechanism.executeSelectCall(DatasourceCallQueryMechanism.java:264)
           at org.eclipse.persistence.internal.queries.DatasourceCallQueryMechanism.selectAllRows(DatasourceCallQueryMechanism.java:646)
           at org.eclipse.persistence.internal.queries.ExpressionQueryMechanism.selectAllRowsFromTable(ExpressionQueryMechanism.java:2592)
           at org.eclipse.persistence.internal.queries.ExpressionQueryMechanism.selectAllRows(ExpressionQueryMechanism.java:2551)
           at org.eclipse.persistence.queries.ReadAllQuery.executeObjectLevelReadQuery(ReadAllQuery.java:418)
           at org.eclipse.persistence.queries.ObjectLevelReadQuery.executeDatabaseQuery(ObjectLevelReadQuery.java:1097)
           at org.eclipse.persistence.queries.DatabaseQuery.execute(DatabaseQuery.java:829)
           at org.eclipse.persistence.queries.ObjectLevelReadQuery.execute(ObjectLevelReadQuery.java:1056)
           at org.eclipse.persistence.queries.ReadAllQuery.execute(ReadAllQuery.java:390)
           at org.eclipse.persistence.queries.ObjectLevelReadQuery.executeInUnitOfWork(ObjectLevelReadQuery.java:1144)
           at org.eclipse.persistence.internal.sessions.UnitOfWorkImpl.internalExecuteQuery(UnitOfWorkImpl.java:2863)
           at org.eclipse.persistence.internal.sessions.AbstractSession.executeQuery(AbstractSession.java:1501)
           at org.eclipse.persistence.internal.sessions.AbstractSession.executeQuery(AbstractSession.java:1483)
           at org.eclipse.persistence.internal.sessions.AbstractSession.executeQuery(AbstractSession.java:1457)
           at org.eclipse.persistence.internal.jpa.EJBQueryImpl.executeReadQuery(EJBQueryImpl.java:485)
           at org.eclipse.persistence.internal.jpa.EJBQueryImpl.getResultList(EJBQueryImpl.java:742)
           at projapis.projrollup.beans.ManagedHolidayDAOBean.locateByDate(ManagedHolidayDAOBean.java:96)
           at projapis.ms.project.ExtractProjectPlan.autoResourceMapping(ExtractProjectPlan.java:716)
           at projapis.ms.project.ExtractProjectPlan.extract(ExtractProjectPlan.java:542)
           at projapis.ms.project.ExtractProjectPlan.main(ExtractProjectPlan.java:994)
      Caused by: java.sql.SQLSyntaxErrorException: ORA-00936: missing expression

           at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:440)
           at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:396)
           at oracle.jdbc.driver.T4C8Oall.processError(T4C8Oall.java:837)
           at oracle.jdbc.driver.T4CTTIfun.receive(T4CTTIfun.java:445)
           at oracle.jdbc.driver.T4CTTIfun.doRPC(T4CTTIfun.java:191)
           at oracle.jdbc.driver.T4C8Oall.doOALL(T4C8Oall.java:523)
           at oracle.jdbc.driver.T4CPreparedStatement.doOall8(T4CPreparedStatement.java:207)
           at oracle.jdbc.driver.T4CPreparedStatement.executeForDescribe(T4CPreparedStatement.java:862)
           at oracle.jdbc.driver.OracleStatement.executeMaybeDescribe(OracleStatement.java:1153)
           at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:1275)
           at oracle.jdbc.driver.OraclePreparedStatement.executeInternal(OraclePreparedStatement.java:3576)
           at oracle.jdbc.driver.OraclePreparedStatement.executeQuery(OraclePreparedStatement.java:3620)
           at oracle.jdbc.driver.OraclePreparedStatementWrapper.executeQuery(OraclePreparedStatementWrapper.java:1491)
           at org.eclipse.persistence.internal.databaseaccess.DatabaseAccessor.executeSelect(DatabaseAccessor.java:931)
           at org.eclipse.persistence.internal.databaseaccess.DatabaseAccessor.basicExecuteCall(DatabaseAccessor.java:607)
           ... 25 more