保存/检索数据库中的二进制数据 [英] Saving/Retrieving Binary data from database

查看:88
本文介绍了保存/检索数据库中的二进制数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在tomcat 6.0.32 x64中部署了一个web应用程序,它使用Hibernate 3.0连接Postgres 9.0 x64数据库。


$ b 该应用程序将二进制字段保存在数据库,当我找到它时,它是不同的。



保存的二进制文件:
[-82,120,71,23,-88,67,36 ,30,57,-72,42,29,-64,93,-8,-103,-63,124,66,20]

获得的二元期权:
[-67,55,56,52,55,49,55,97,56,52,51, 100,99,48,53,100,102,56,57,57,99,49,55,99,52,50,49,52]


解决方案

检查您的postgres jdbc驱动程序版本。它应该至少和你的数据库服务器一样近,所以你需要一个9.0或更高的驱动程序。



我相信9.0中的bytea wire格式有所改变,如果您有旧的驱动程序,可以解释此问题。


I have a web app deployed in tomcat 6.0.32 x64 and it's using Hibernate 3.0 to connect a Postgres 9.0 x64 database.

The app saves a binary field in the database and when I find it, it is different.

Binary Saved: [-82, 120, 71, 23, -88, 67, 36, 30, 57, -72, 42, 29, -64, 93, -8, -103, -63, 124, 66, 20]

Binary Obtained: [-67, 55, 56, 52, 55, 49, 55, 97, 56, 52, 51, 50, 52, 49, 101, 51, 57, 98, 56, 50, 97, 49, 100, 99, 48, 53, 100, 102, 56, 57, 57, 99, 49, 55, 99, 52, 50, 49, 52]

Thanks

解决方案

Check your postgres jdbc driver version. It should be at least as recent as your DB server, so you need a 9.0 driver or better.

I believe the bytea wire format changed in 9.0, which could explain this problem if you have an old driver.

这篇关于保存/检索数据库中的二进制数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆