How to set numeric in PreparedStatement
От | Aaron Brashears |
---|---|
Тема | How to set numeric in PreparedStatement |
Дата | |
Msg-id | 20010321232056.A10302@gila.org обсуждение исходный текст |
Ответы |
Re: How to set numeric in PreparedStatement
|
Список | pgsql-jdbc |
I want to set a numeric in a prepared statement, but I'm getting a nasty exception for a simple query. The code is simple, and all I want to do is query for a numeric type. Here's the simplified data model: create table account ( id varchar(3) primary key, balance numeric(10,2)); And a code snippet that generates the exception: ... PreparedStatement pstmt = connectoin.prepareStatement( "select id from account where balance > ? and balance < ?"; pstmt.setDouble( 1, 10.0 ); pstmt.setDouble( 2, 100.0 ); ResultSet rs = pstmt.executeQuery(); ... And finally, the exception thrown: Exception in thread "main" java.sql.SQLException: ERROR: Unable to identify an operator '>' for types 'numeric' and 'float8' You will have to retype this query using an explicit cast at org.postgresql.Connection.ExecSQL(Connection.java:398) at org.postgresql.jdbc2.Statement.execute(Statement.java:273) at org.postgresql.jdbc2.Statement.executeQuery(Statement.java:54) at org.postgresql.jdbc2.PreparedStatement.executeQuery(PreparedStatement.java:101) at SQLTest.main(SQLTest.java:16) How can I accomplish this? I'm running postgresql 7.0.3 with the jdbc2 driver.
В списке pgsql-jdbc по дате отправления: