2011-07-12 40 views

cevap

59

mySql damla sınıfı aşağıdaki işlevi vardır:

blob.getBytes

bu gibi kullanmak:

//(assuming you have a ResultSet named RS) 
Blob blob = rs.getBlob("SomeDatabaseField"); 

int blobLength = (int) blob.length(); 
byte[] blobAsBytes = blob.getBytes(1, blobLength); 

//release the blob and free up memory. (since JDBC 4.0) 
blob.free(); 
+0

Teşekkürler, aslında blob getbytes() yöntemine sahip değil, yalnızca serialblob getbytes() yöntemini kullanıyor. Blob için bunu yapmak için. – androidGuy

+0

'java.sql.Blob' kullanıyor musunuz? –

+5

Aramaktan kaçının 'blob.free()' –

39

en kolay yolu budur.

byte[] bytes = rs.getBytes("my_field"); 
+5

+1 benden daha iyi olduğu için :) –

İlgili konular