Hello guys,
I was wondering if it would make sense for H2 to provide better database
interoperability for BOOLEAN bind values when they're inserted into
non-BOOLEAN columns. Consider this test scenario:
create table test(val varchar(1));
Now this program fails:
Connection c = getConnection();
PreparedStatement s = c.prepareStatement("insert into test values (?)");
s.setBoolean(1, true);
s.executeUpdate(); // H2 fails here
s = c.prepareStatement("select * from test");
ResultSet rs = s.executeQuery();
rs.next();
System.out.println(rs.getString(1));
The exception I get is this:
org.h2.jdbc.JdbcSQLException: Wert zu gross / lang für Feld "VAL
VARCHAR(1)": "'TRUE' (4)"
Value too long for column "VAL VARCHAR(1)": "'TRUE' (4)"; SQL statement:
insert into test values (?) [22001-170]
at org.h2.message.DbException.getJdbcSQLException(DbException.java:329)
at org.h2.message.DbException.get(DbException.java:169)
at org.h2.table.Column.validateConvertUpdateSequence(Column.java:315)
at org.h2.table.Table.validateConvertUpdateSequence(Table.java:689)
at org.h2.command.dml.Insert.insertRows(Insert.java:120)
at org.h2.command.dml.Insert.update(Insert.java:84)
at org.h2.command.CommandContainer.update(CommandContainer.java:75)
at org.h2.command.Command.executeUpdate(Command.java:230)
at
org.h2.jdbc.JdbcPreparedStatement.executeUpdateInternal(JdbcPreparedStatement.java:156)
at
org.h2.jdbc.JdbcPreparedStatement.executeUpdate(JdbcPreparedStatement.java:142)
at org.jooq.test._.testcases.EnumTests.testCustomEnums(EnumTests.java:140)
The same statement works perfectly with Oracle, which returns 1.
This is just loud thinking, I'm not sure if it would be wise to change this
behaviour in H2.
Cheers
Lukas
--
You received this message because you are subscribed to the Google Groups "H2
Database" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/h2-database.
For more options, visit https://groups.google.com/groups/opt_out.