I'm running into a bit of a situation in corner cases when binding null to a PreparedStatement with Firebird's jaybird JDBC driver. Here's a sample statement:
// Observe the "local" in the connection string!
Connection con = DriverManager.getConnection(
"jdbc:firebirdsql:local:C:/data/firebird/test.db", "TEST", "TEST");
// With this connection, I'm not able to reproduce the issue:
Connection con1 = DriverManager.getConnection(
"jdbc:firebirdsql:localhost:C:/data/firebird/test.db", "TEST", "TEST");
PreparedStatement stmt = con.prepareStatement(
"SELECT cast(? as varchar(1)) FROM rdb$database");
ResultSet rs = stmt.executeQuery();
The output of the above program is
The first line being an empty string. It really should be
Changing this line ...
... into any of these lines ...
... doesn't help either. A workaround is to inline null literals in SQL statements, instead of binding them to the prepared statement. What am I missing?
Database: Firebird WI-V220.127.116.11351
JDBC driver: jaybird-2.2.0
Java version: JDK 1.6.0_24
OS: Windows 7 x64
JDBC Connection String: See above.