Hi Derby community,
I'm currently using Derby on a freshly started project, and I ran into an
issue which seems to be a bug.
Indeed the same code works well with the Client Driver, and not with the
Embedded Driver. The error I get from Derby is:
org.apache.derby.impl.jdbc.EmbedSQLException: An attempt was made to get a
data value of type 'VARCHAR' from a data value of type 'VARBINARY'
Here is a code snippet reproducing the problem:
////////////////////////////////////////
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.Types;
import org.apache.derby.jdbc.ClientDriver;
import org.apache.derby.jdbc.EmbeddedDriver;
public class DerbyTest {
public static void main(String[] args) throws Exception {
Class.forName(EmbeddedDriver.class.getName());
// Class.forName(ClientDriver.class.getName());
Connection con =
DriverManager.getConnection("jdbc:derby:test;create=true",
"app", "app");
// Connection con =
DriverManager.getConnection("jdbc:derby://localhost:1527/test;create=true",
"app", "app");
try {
con.createStatement().executeUpdate("create table Issue ( ID
char(50) )");
PreparedStatement st = con.prepareStatement("select count(*)
from Issue where ? is null");
st.setNull(1, Types.VARBINARY);
ResultSet rs = st.executeQuery();
System.out.println(rs.next());
} finally {
con.close();
}
}
}
////////////////////////////////////////
If you switch to the ClientDriver, it's working properly.
Is it a bug? Or is it an incorrect use of the JDBC API, working with client
driver by chance?
FYI, here's some details on my environment:
Derby 10.2.2.0
Sun Windows JDK 6.0
Xavier
--
Learn Ivy at ApacheCon: http://www.eu.apachecon.com/
Manage your dependencies with Ivy!
http://incubator.apache.org/ivy/