The sample table is created as below to have a blob field to store file.
CREATE TABLE t1 (c1 INT PRIMARY KEY NOT NULL, c2 BLOB(5M));
Then use the below code snippet to insert an image file as follows.
PreparedStatement pstmt = conn.prepareStatement ("INSERT INTO t1 VALUES (?,?)");
pstmt.setInt (1, 100);
File fBlob = new File ( "image1.gif" );
FileInputStream is = new FileInputStream ( fBlob );
pstmt.setBinaryStream (2, is, (int) fBlob.length() );
pstmt.execute ();
...
Retrieving a BLOB or in other words retrieving the image file stored in the database as follows:
Statement stmt = conn.createStatement ();
ResultSet rs= stmt.executeQuery("SELECT * FROM t1");
while(rs.next()) {
int val1 = rs.getInt(1);
InputStream val2 = rs.getBinaryStream(2);
...
} rs.close();
分享到:
相关推荐
CodedUI for Image save/read
How to save data from a DataSet into a T-SQL table。
// Save a TBitMap image to a ZIP archive. // Create and initialize a bitmap image. Img := TBitMap.Create; // Add a new entry to the ZIP archive. DIZipWriter.AddEntry('MyImage'); // Write the ...
System.Drawing.Image.FromStream 出现参数无效的解决方法
save image to image.raw load image raw to data
->toFile('new-image.png', 'image/png') // convert to PNG and save a copy to new-image.png ->toScreen(); // output to the screen // And much more! } catch(Exception $err) { // Handle errors echo...
* Creates new frame image from current data (and previous * frames as specified by their disposition codes). */ protected void setPixels() { // expose destination image's pixels as int array int...
allows the user to read/write data to Flash. This is particularly useful in embedded devices that wish to save some persistent data between reboots. For more information on YAFFS/YAFFS2 please see the...
Intervention Image 是一个 PHP 图像处理和操作库,它提供了一个简单的,易于表达的方式来创建、编辑图片。...// save image in desired format $img->save('public/bar.jpg'); 标签:Intervention
操纵Excel极好的控件,包含源代码、例程、帮助FlexCel Reports is a suite of Delphi 5/6/7 components allowing to create Excel files by substituting values into a Template from a database or variables....
// from 2003-02-28 to 2003-03-05 where white (255,255,255) in a bitmap // // was converted to (254,254,254) in the gif. // // The doCreateOptimizedPaletteFromSingleBitmap function and // // the ...
Save/Load SQL scripts to/from file. 10. Transaction support. SQLite supports one level of transactions. 11. Data mapping. SQLite Expert supports custom data types, and 40 predefined data types. ...
-Resource viewer/editor (save/replace ico/cur/bmp); Pe Scanner (PEiD sig database): -400 packers/protectors/compilers; Task viewer/dumper/killer; PEHeader/Binary file compare; RVA to RAW to RVA...
9. Save/Load SQL scripts to/from file. 10. Transaction support. SQLite supports one level of transactions. 11. Data mapping. SQLite Expert supports custom data types, and 40 predefined data types. ...
SQL数据库中关于图片的存储和读取方法,很经典
9. Save/Load SQL scripts to/from file. 10. Transaction support. SQLite supports one level of transactions. 11. Data mapping. SQLite Expert supports custom data types, and 40 predefined data types. ...
save要保存到的文件名(包含路径) format图片的根式,根据图片相应的类型指定。目前可用以下参数 image/bmp image/jpeg image/gif image/tiff image/png width指定图片宽度 height指定图片高度...
Using openCV to load image, and transfer to gray and save image.
Html2Image html2Image = Html2Image.fromHtml(sb.toString(),null); // 这边如果设置false,图片不会自动根据内容设置长宽默认长1024 ,宽768 //html2Image.getImageRenderer().setAutoHeight(false); ...
a GUI code in Matlab for read and write on Serial Port, And Save Data in a xls file