bytea类型上传下载图片.txt

时间:2022-12-19 05:22:05
【文件属性】:

文件名称:bytea类型上传下载图片.txt

文件大小:3KB

文件格式:TXT

更新时间:2022-12-19 05:22:05

pgsql

try { String strSQL = ""; int k=0,n=0; Connection dbConn = null; PreparedStatement dbStat = null; //ResultSet dbRs = null; dbConn = JDBCUtil.getConnectionELIB(); //上传图片 File file=new File("C:\\Users\\Administrator\\Desktop\\东莞市经济贸易学校图书馆新生读者导入原始资料\\2018"); File [] firstfiles = file.listFiles(); for (int x = 0; x < firstfiles.length; x++){ File [] secondfiles = firstfiles[x].listFiles(); for (int i = 0; i < secondfiles.length; i++){ File file_i = secondfiles[i]; String filename=file_i.getName().trim(); //根据后缀判断 String xjh=""; for(int j=0;j=48 && filename.charAt(j)<=57){ xjh+=filename.charAt(j); } } strSQL="INSERT INTO picture(xjh, zpian) VALUES (?, ?);"; dbStat = dbConn.prepareStatement(strSQL); dbStat.setString(1, xjh); // 设置图片文件 FileInputStream inputStream = new FileInputStream(file_i); dbStat.setBinaryStream(2, inputStream, (int) file_i.length()); // 执行SQL dbStat.execute(); k++; } System.out.println(firstfiles[x].getName()+":"+k); n+=k; k=0; } dbStat.close(); System.out.println("总量:"+n);


网友评论