Tried it with the latest h2-1.3.166.jar (earlier I was using 
'h2-1.3.160.jar'), and now am getting the following DataConversion 
exception.

Looks like it is trying to convert 0.1 into an int. Is it possible to 
convert it into a double when the data is of double type.

org.h2.jdbc.JdbcSQLException: Data conversion error converting "0.1"; SQL 
statement:
SELECT 1 - '0.1' FROM DUAL [22018-166]
at org.h2.message.DbException.getJdbcSQLException(DbException.java:329)
at org.h2.message.DbException.get(DbException.java:158)
at org.h2.value.Value.convertTo(Value.java:852)
at org.h2.expression.Operation.getValue(Operation.java:115)
at org.h2.expression.Operation.optimize(Operation.java:317)
at org.h2.command.dml.Select.prepare(Select.java:799)
at org.h2.command.Parser.prepareCommand(Parser.java:218)
at org.h2.engine.Session.prepareLocal(Session.java:415)
at org.h2.engine.Session.prepareCommand(Session.java:364)
at org.h2.jdbc.JdbcConnection.prepareCommand(JdbcConnection.java:1111)
at org.h2.jdbc.JdbcPreparedStatement.<init>(JdbcPreparedStatement.java:71)
at org.h2.jdbc.JdbcConnection.prepareStatement(JdbcConnection.java:266)
......
Caused by: java.lang.NumberFormatException: For input string: "0.1"
at java.lang.NumberFormatException.forInputString(Unknown Source)
at java.lang.Integer.parseInt(Unknown Source)
at java.lang.Integer.parseInt(Unknown Source)
at org.h2.value.Value.convertTo(Value.java:809)
... 33 more

On Tuesday, June 26, 2012 3:31:09 PM UTC-4, Vinod wrote:
>
> I am executing dual queries using H2(in memory).
> But the results do not seem correct.
>
> ---------------------------------
> ***Without bind variables:
> ---------------------------------
> SELECT 1 - '0.1' FROM DUAL
> Output=0 [OracleOutput: 0.9]
> ---------------------------------
>
> ---------------------------------
> ***Using bind variables:
> ---------------------------------
> SELECT 1 - ? FROM DUAL
> stmt.setString(1, "0.1");
> Output: 0 [OracleOutput: 0.9]
>
> -- tried double
> SELECT 1 - ? FROM DUAL
> stmt.setDouble(1, 0.1);
> Output: 1 [OracleOutput: 0.9]
>
> SELECT (? - (1 -?) * ?) FROM DUAL
> set bind variables ["0.95", "1", "0.025"] using setString.
> Output: 1 [OracleOutput: 0.95]
> ---------------------------------
>
> Am I missing something? I am already using "MODE=Oracle" while creating 
> connection.
>
> Any help would be much appreciated.
>

-- 
You received this message because you are subscribed to the Google Groups "H2 
Database" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/h2-database/-/h3TLzxLyJKkJ.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/h2-database?hl=en.

Reply via email to