Skip to content

jdbc: BLOB type roundtrip fails #45

Closed
@ztarvos

Description

@ztarvos

Values of BINARY/VARBINARY columns are selected back as strings when initially inserted as byte arrays in a prepared statement.

CREATE TABLE testbin(id INT PRIMARY KEY, b VARBINARY)

PreparedStatement prep = conn.prepareStatement("INSERT INTO testbin(id, b) VALUES (1, ?)");
prep.setBytes(1, new BigInteger("ABCD", 16).toByteArray());
prep.executeUpdate();
...
ResultSet rs = stmt.executeQuery("SELECT b FROM testbin");
rs.next();
rs.getBytes(1) - fails.

Exception in thread "main" java.lang.ClassCastException: java.lang.String cannot be cast to [B at org.tarantool.jdbc.SQLResultSet.getBytes(SQLResultSet.java:133) at TestJdbcBinary.main(TestJdbcBinary.java:32)

But when inserted as X’hexstring’ in a basic statement, the value that gets back is byte[].

INSERT INTO testbin(id, b) VALUES(1, X'ABCD') -- OK, select returns byte[]

Metadata

Metadata

Assignees

Labels

bugSomething isn't workingjdbc

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions