Thread: parser: parse error at or near "-"

parser: parse error at or near "-"

From
"zhan yi"
Date:
hi,
 
I am developing an accounting application using postgresql 7.2.2 and pg72jdbc2.jar. I met following exception when execute a query:
 
java.sql.SQLException: ????:  parser: parse error at or near "-"
 
 at org.postgresql.core.QueryExecutor.execute(QueryExecutor.java:94)
 at org.postgresql.Connection.ExecSQL(Connection.java:398)
 at org.postgresql.jdbc2.Statement.execute(Statement.java:130)
 at org.postgresql.jdbc2.Statement.executeQuery(Statement.java:54)
 at org.postgresql.jdbc2.PreparedStatement.executeQuery(PreparedStatement.java:99)
 at org.apache.commons.dbcp.DelegatingPreparedStatement.executeQuery(DelegatingPreparedStatement.java:179)
 at db.TeleRateTable.selectAll(TeleRateTable.java:36)
 at org.apache.jsp.admin_jsp._jspService(admin_jsp.java:737)
......
 
the sql string is:
    select * from teleRateTable ORDER BY char_length(prefix), prefix LIMIT ? OFFSET ?
 
Any hint on solving this problem is appreciated.
 
regards
zhanyi

Re: parser: parse error at or near "-"

From
"Nick Fankhauser"
Date:
Is there any chance that a "-" is getting substituted into the ? values for offset or limit, thus causing the parse error because an integer is expected? Since there is no "-" in the prepared statement, I'd look to the substitution variables for the problem.
 
-Nick
-----Original Message-----
From: pgsql-jdbc-owner@postgresql.org [mailto:pgsql-jdbc-owner@postgresql.org]On Behalf Of zhan yi
Sent: Monday, August 11, 2003 9:11 PM
To: pgsql-jdbc@postgresql.org
Subject: [JDBC] parser: parse error at or near "-"

hi,
 
I am developing an accounting application using postgresql 7.2.2 and pg72jdbc2.jar. I met following exception when execute a query:
 
java.sql.SQLException: ????:  parser: parse error at or near "-"
 
 at org.postgresql.core.QueryExecutor.execute(QueryExecutor.java:94)
 at org.postgresql.Connection.ExecSQL(Connection.java:398)
 at org.postgresql.jdbc2.Statement.execute(Statement.java:130)
 at org.postgresql.jdbc2.Statement.executeQuery(Statement.java:54)
 at org.postgresql.jdbc2.PreparedStatement.executeQuery(PreparedStatement.java:99)
 at org.apache.commons.dbcp.DelegatingPreparedStatement.executeQuery(DelegatingPreparedStatement.java:179)
 at db.TeleRateTable.selectAll(TeleRateTable.java:36)
 at org.apache.jsp.admin_jsp._jspService(admin_jsp.java:737)
......
 
the sql string is:
    select * from teleRateTable ORDER BY char_length(prefix), prefix LIMIT ? OFFSET ?
 
Any hint on solving this problem is appreciated.
 
regards
zhanyi

Re: parser: parse error at or near "-"

From
"zy7111"
Date:
I am sorry wasting your time. I made a mistake in my program. I saw the query in the database log: select * from
teleRateTableORDER BY char_length(prefix), prefix LIMIT 16 OFFSET -16. Where -16 is the fail reason. 

>
> hi,
>
> I am developing an accounting application using postgresql
> 7.2.2 and pg72jdbc2.jar. I met following exception when execute a query:
>
> java.sql.SQLException: ????:  parser: parse error at or
> near "-"
>
>  at
> org.postgresql.core.QueryExecutor.execute(QueryExecutor.java:94)
>  at
> org.postgresql.Connection.ExecSQL(Connection.java:398)
>  at
> org.postgresql.jdbc2.Statement.execute(Statement.java:130)
>  at
> org.postgresql.jdbc2.Statement.executeQuery(Statement.java:54)
>  at
> org.postgresql.jdbc2.PreparedStatement.executeQuery(PreparedStatement.java:99)
>  at
> org.apache.commons.dbcp.DelegatingPreparedStatement.executeQuery(DelegatingPreparedStatement.java:179)
>  at
> db.TeleRateTable.selectAll(TeleRateTable.java:36)
>  at
> org.apache.jsp.admin_jsp._jspService(admin_jsp.java:737)
> ......
>
> the sql string is:
>     select * from teleRateTable ORDER BY
> char_length(prefix), prefix LIMIT ? OFFSET ?
>
> Any hint on solving this problem is
> appreciated.
>
> regards
> zhanyi
>
----------------------------------------------------------------------
�Ҵ��ڣ���Ϊ�����й��ˣ�������ע�л���������
������֮�շ��ʣ�http://paymail.china.com
������֮�����ʣ�http://mail.china.com