English 中文(简体)
postgresql / greenplum parameter binding on jdbc, why does it think its a column name?
原标题:

I have a query that looks something like this:

SELECT A.A, A.B, B.A, B.C, B.D
FROM tableone A, tabletwo B
WHERE A.A = B.A
AND B.C = :p_name

When the param :p_name is set to FOO I get an error like this:

[42703] ERROR: column "FOO" does not exist

When I manually set it to include single quotes FOO it works.

I ve tried padding escaped single quotes. I ve tried the quote_* functions. I ve ried using "@" "$" and "?" params stypes. This keeps popping up.

EDIT

Eliminating as much as I can, I tried the following from the sql console in IntelliJ

SELECT * from A where A.B = :p1 
SELECT * from A where A.B = ? 
SELECT * from A where A.B = @p1

And adding "Foo" the parameter to in the edit box. In all three cases, I get the same problem. When I add Foo to the edit box, I get the results I expect.

I also used preparedStatement and ? rather than callableStatement with :p1 and also got the same results.

What am I doing wrong?

EDIT

Removing "stringtype=unspecified" from the JDBC URL seems to make the problem go away. This is why you shouldn t just copy snippets or other peoples code and just assume it will work for you.

问题回答

暂无回答




相关问题
MaxPooledStatements setting in JDBC oracle

I can t figure out how to set MaxPooledStatements in Oracle using the Oracle thin JDBC driver. Could someone point me in the right direction?

pass ResultSet from servlet to JSP

I am doing the following in my SampleServlet.java //Fill resultset from db .... try { ArrayList Rows = new ArrayList(); while (resultSet.next()){ ArrayList row = new ArrayList(); ...

How to correctly use ResultSet with h:dataTable

The problem is, that after displaying the ResultSet with <h:dataTable>, the connection is left open. If I close it, it closes the ResultSet too. I m thinking about copying the ResultSet data ...

Mysql session variable in JDBC string

am using this connection string to connect to mysql from java: jdbc:mysql://localhost:3306/db?noDatetimeStringSync=true&useUnicode=yes&characterEncoding=UTF-8 is it possible to set the ...

热门标签