sqlserver数据库存储图片
1 /** 2 * 存储图片方法测试 3 */ 4 public static void pictureStoreSqlserver(){ 5 try { 6 7 FileInputStream fis = null; 8 File file = new File("C:/Users/v-guoxiao/Desktop/ReferencePicture/image1.jpeg"); 9 System.out.println(file); 10 fis = new FileInputStream(file); 11 12 PreparedStatement preparedStatement = connection.prepareStatement("Insert into referencepicture (id,bytepic) values (?,?)"); 13 preparedStatement.setString(1, "1"); 14 preparedStatement.setBinaryStream(2, fis, file.length()); 15 preparedStatement.executeUpdate(); 16 preparedStatement.close(); 17 fis.close(); 18 } catch (SQLException e)