當前位置:首頁 » 操作系統 » 資料庫音頻文件

資料庫音頻文件

發布時間: 2025-09-30 05:13:14

㈠ 如何在mysql 或者 其他的資料庫中存放圖片 音頻 視頻

採用大對象類型。 mysql 大對象存取: 類型一般應該用mediumblod, blob只能存2的16次方個byte, mediumblod是24次方, 一般來說夠用了.longblob是32次方有些大. MYSQL默認配置只能存1M大小的文件,要修改配置,WIN版本的在mysql.ini文件中 修改max_allowed_packet,net_buffer_length等幾個參數,或直接SET GLOBAL varName=value. linux版本可以在啟動參數後加-max_allowed_packet=xxM等幾個參數. MYSQL存大對象最好直接就setBinaryStream,又快又方便. 而不要先插入空再造型成BLOB然後再setBlob 例子: import java.sql.*; import java.io.*; public class DBTest { static String driver = "org.gjt.mm.mysql.Driver"; static String url = "jdbc:mysql://localhost:3306/test"; static String user = "root"; static String passwd = "passwd"; public static void main(String[] args) throws Exception { Connection conn = null; try { Class.forName(driver); conn = DriverManager.getConnection(url,user,passwd); int op = 1; //插入 if (op == 0) { PreparedStatement ps = conn.prepareStatement("insert into tb_file values (?,?)"); ps.setString(1, "aaa.exe"); InputStream in = new FileInputStream("d:/aaa.exe"); ps.setBinaryStream(2,in,in.available()); ps.executeUpdate(); ps.close(); } else { //取出 PreparedStatement ps = conn.prepareStatement("select * from tb_file where filename = ?"); ps.setString(1, "aaa.exe"); ResultSet rs = ps.executeQuery(); rs.next(); InputStream in = rs.getBinaryStream("filecontent"); System.out.println(in.available()); FileOutputStream out = new FileOutputStream("d:/bbb.exe"); byte[] b = new byte[1024]; int len = 0; while ( (len = in.read(b)) != -1) { out.write(b, 0, len); out.flush(); } out.close(); in.close(); rs.close(); ps.close(); } } catch (Exception ex) { e

㈡ 如何在ACCESS資料庫里存放照片和音頻視頻

創建資料庫連接。

使用OleDbConnection。

保存圖片到Access資料庫。

將圖片轉成二進制流存到資料庫中,使用OleDbCommand命令。

保存成功後,資料庫中圖像欄位顯示為「長二進制數據」。

讀取資料庫中的圖片。

將讀出的圖片數據轉成位元組數組,而後轉成圖片顯示。

熱點內容
java返回this 發布:2025-10-20 08:28:16 瀏覽:739
製作腳本網站 發布:2025-10-20 08:17:34 瀏覽:1002
python中的init方法 發布:2025-10-20 08:17:33 瀏覽:707
圖案密碼什麼意思 發布:2025-10-20 08:16:56 瀏覽:871
怎麼清理微信視頻緩存 發布:2025-10-20 08:12:37 瀏覽:770
c語言編譯器怎麼看執行過程 發布:2025-10-20 08:00:32 瀏覽:1117
郵箱如何填寫發信伺服器 發布:2025-10-20 07:45:27 瀏覽:344
shell腳本入門案例 發布:2025-10-20 07:44:45 瀏覽:221
怎麼上傳照片瀏覽上傳 發布:2025-10-20 07:44:03 瀏覽:907
python股票數據獲取 發布:2025-10-20 07:39:44 瀏覽:866