org.h2.jdbc.JdbcSQLException: Unknown data type: """?1"""; SQL statement:
SELECT * FROM (SELECT ? FROM DUAL) [50004-192]
at org.h2.message.DbException.getJdbcSQLException(DbException.java:345)
at org.h2.message.DbException.get(DbException.java:179)
at org.h2.message.DbException.get(DbException.java:155)
at org.h2.table.Table.setColumns(Table.java:425)
at org.h2.table.TableView.initColumnsAndTables(TableView.java:220)
at org.h2.table.TableView.init(TableView.java:98)
at org.h2.table.TableView.<init>(TableView.java:65)
at org.h2.table.TableView.createTempView(TableView.java:535)
at org.h2.command.Parser.readTableFilter(Parser.java:1168)
Code to reproduce:
PreparedStatement st = cnx.prepareStatement("SELECT * FROM (SELECT ? FROM DUAL)");
st.setTimestamp(1, new Timestamp(System.currentTimeMillis()));
rs = st.executeQuery();
rs.next();
System.out.println(rs.getObject(1));
rs.close();
st.close();
"SELECT ? FROM DUAL" works fine.
The problems is that the type of the parameter cannot be known when the statement is prepared so I'm not sure how the parser should deal with that.
Boris.