MYSQL存取图片(文件).docVIP

  • 14
  • 0
  • 约9.42千字
  • 约 11页
  • 2017-11-17 发布于河南
  • 举报
MYSQL存取图片(文件)

一、 首先,需要知道,数据库本身也存储在硬盘上,也是一种文件,所以数据库存取文件是可能的,那么在存储文件时,要注意两点 1.MYSQL图片(文件)的类型是blob 2.写入数据库的文件必须是二进制流 首先,我们就在MYSQL中建立数据库 SQL脚本如下 view plaincopy to clipboardprint? /*source [SQL文件的URL]*/? drop database if exists testImage;?? ? create database testImage;?? ? use testImage;?? ? create table myTable(?? ?id int primary key,?? image blob?? );? /*source [SQL文件的URL]*/ drop database if exists testImage; create database testImage; use testImage; create table myTable( ?id int primary key, image blob ); 有了这个脚本,就可以进行编码存储图片了,这里给出存取的关键代码 存: view plaincopy to clipboardprint? Class.forName(com.java.m

文档评论(0)

1亿VIP精品文档

相关文档