在官方的postgresql jdbc驱动程序中,在setBlob方法内,将为要设置的大对象生成一个OID。
例如:
try (Connection connection = DriverManager
.getConnection("jdbc:pgsql://localhost:5432/typetestdb", "postgres", "123");
PreparedStatement stmt = connection.prepareStatement("select * from BlobTable where blob_type=?")) {
stmt.setBlob(1, new ByteArrayInputStream("someval".getBytes()));
ResultSet resultSet = stmt.executeQuery();
} catch (SQLException e) {
// Handle exception
}
在这里,我们要检查实际blob值是否相等,但是由于setBlob创建了OID,因此两个大对象将有所不同。因此,返回的结果集将始终为空。
因此,在where子句中使用OID类型似乎没有任何意义。
我的理解正确吗?