1) 당신이 가정 DB 사용 ResultSet.getBlob
에서 BLOB를 읽어
3 PreparedStatement.setBlob
)를 사용하여 DB에 BLOB를 작성하는 BLOB 사용 Connection.createBlob
2)를 만들 수 있습니다 테이블 t1 (BLOB 열 포함) b1 :
Connection conn = DriverManager.getConnection("jdbc:mysql://localhost:3306/test", "root", "root");
Blob b1 = conn.createBlob();
b1.setBytes(1, new byte[10]); // first position is 1. Otherwise you get: Value of offset/position/start should be in the range [1, len] where len is length of Large Object[LOB]
PreparedStatement ps = conn.prepareStatement("update t1 set c1 = ?");
ps.setBlob(1, b1);
ps.executeUpdate();
Statement st = conn.createStatement();
ResultSet rs = st.executeQuery("select c1 from t1");
Blob b2 = rs.getBlob(1);
왜 BLOB 개체를 만들어야합니까? 또는 DB에서 BLOB 데이터를 읽으려고합니까? – NINCOMPOOP
db에서 BLOB 값을 가져오고이 값을 BLOB 객체에 저장하려고합니다. 그래서 object.After를 다시 저장하고 싶습니다. 다시이 값을 다른 db에 저장하고 싶습니다. 해당 값을 가져오고 싶습니다. 스프링 프레임 워크를 사용하고 있습니다. – vijayk
[DB2와 Oracle 모두에서 Java를 사용하여 BLOB 삽입]의 중복 가능 (http://stackoverflow.com/questions/16462060/insert-blob-using-java-for-both-db2-and-oracle) –