Welcome to the new Gigaspaces XAP forum. To recover your account, please follow these instructions.

Ask Your Question
0

SQLQueryException: Failed to execute SQLQuery

I'm getting an SQLQueryException, can you tell me if this is correct?

SQLQuery<messageentry> query = new SQLQuery<messageentry>(MessageEntry.class, "timestamp >= ? AND timestamp <= ?"); query.setParameter(1, minTimestamp); query.setParameter(2, maxTimestamp); gigaSpaceClustered.takeMultiple(query);

where MessageEntry has a field Long timestamp (with getTimestamp() and setTimestamp() methods)

StackTrace: com.j_spaces.core.client.sql.SQLQueryException: Failed to execute SQLQuery : [timestamp >= ? AND timestamp <= ?] at com.j_spaces.core.client.sql.QueryManager.readTake(QueryManager.java:187) at com.j_spaces.core.client.sql.QueryManager.readTakeMultiple(QueryManager.java:148) at com.gigaspaces.internal.client.spaceproxy.actions.SpaceProxyImplReadTakeMultipleAction.newReadTakeMultiple(SpaceProxyImplReadTakeMultipleAction.java:85) at com.gigaspaces.internal.client.spaceproxy.actions.SpaceProxyImplReadTakeMultipleAction.takeMultiple(SpaceProxyImplReadTakeMultipleAction.java:58) at com.gigaspaces.internal.client.spaceproxy.actions.SpaceProxyImplReadTakeMultipleAction.takeMultiple(SpaceProxyImplReadTakeMultipleAction.java:26) at com.gigaspaces.internal.client.spaceproxy.actions.AbstractSpaceProxyActionManager.takeMultiple(AbstractSpaceProxyActionManager.java:400) at com.gigaspaces.internal.client.spaceproxy.AbstractSpaceProxy.takeMultiple(AbstractSpaceProxy.java:357) at org.openspaces.core.DefaultGigaSpace.takeMultiple(DefaultGigaSpace.java:1124) at org.openspaces.core.DefaultGigaSpace.takeMultiple(DefaultGigaSpace.java:1118)

Caused by: java.sql.SQLException: Error in statement [timestamp >= ? AND timestamp <= ?]; Cause: com.j_spaces.jdbc.parser.grammar.ParseException: Encountered " "timestamp" "timestamp "" at line 1, column 1. Was expecting one of: <EOF> "rownum" ... <IDENTIFIER> ... <ESC_IDENTIFIER> ... ";" ... "(" ...

at com.j_spaces.core.client.sql.SqlQueryParser.parseSqlQuery(SqlQueryParser.java:103)
at com.j_spaces.core.client.sql.QueryManager.readTake(QueryManager.java:165)
... 33 more

Caused by: com.j_spaces.jdbc.parser.grammar.ParseException: Encountered " "timestamp" "timestamp "" at line 1, column 1. Was expecting one of: <EOF> "rownum" ... <IDENTIFIER> ... <ESC_IDENTIFIER> ... ";" ... "(" ...

at com.j_spaces.jdbc.parser.grammar.SqlParser.generateParseException(SqlParser.java:3911)
at com.j_spaces.jdbc.parser.grammar.SqlParser.jj_consume_token(SqlParser.java:3787)
at com.j_spaces.jdbc.parser.grammar.SqlParser.deleteSqlQuery(SqlParser.java:312)
at com.j_spaces.core.client.sql.TakeQueryParser.parse(TakeQueryParser.java:31)
at com.j_spaces.core.client.sql.SqlQueryParser.parseSqlQuery(SqlQueryParser.java:66)
... 34 more

]; nested exception is com.gigaspaces.client.TakeMultipleException: Success:0, errors:1, [class com.j_spaces.core.client.sql.SQLQueryException:1

asked 2014-11-04 16:46:51 -0500

dncheu1 gravatar image
edit retag flag offensive close merge delete

Comments

Hi,

What version are you using?

Yuval gravatar imageYuval ( 2014-11-05 10:19:35 -0500 )edit

GigaSpaces XAP: Edition: XAP Premium 9.7.0 GA Build: 10551-9

dncheu1 gravatar imagedncheu1 ( 2014-11-05 11:24:06 -0500 )edit

3 Answers

Sort by ยป oldest newest most voted
0

Hi,

You can solve it by adding escape character (should be backslash) before the timestamp filed in the query.

Yuval

answered 2014-11-06 01:48:53 -0500

Yuval gravatar image
edit flag offensive delete link more
0

Hi,

There is a list of tokens that has special meaning in queries and therefore cant serve as property name,like timestamp ,datetime, number,numeric etc...

Yuval

answered 2014-11-05 13:36:07 -0500

Yuval gravatar image
edit flag offensive delete link more
0

Thanks. I found the answer here http://docs.gigaspaces.com/xap97/quer... I had to use to the backtick ` character to escape the column name.

answered 2014-11-06 11:28:53 -0500

dncheu1 gravatar image
edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2014-11-04 16:46:51 -0500

Seen: 1,722 times

Last updated: Nov 06 '14