将音频文件插入Mysql数据库
我们如何使用 JAVA 数据库连接连接将音频文件插入 MYSQL 数据库
对于插入图像,我们使用
psmnt = conn.prepareStatement("INSERT INTO upload_data(user_id,photo) "
+ "values(?,?)");
psmnt.setLong(1, userId);
fis = new FileInputStream(photoFile);
psmnt.setBinaryStream(2, (InputStream) fis, (int) (photoFile
.length()));
/*
* executeUpdate() method execute specified sql query. Here this
* query insert data and image from specified address.
*/
int s = psmnt.executeUpdate();
要插入 3gp 格式的音频文件,使用 JDBC 的代码是什么
How can we insert audio files in to MYSQL Database using JAVA DATABASE CONNECTIVITY connectivity
For inserting image we use
psmnt = conn.prepareStatement("INSERT INTO upload_data(user_id,photo) "
+ "values(?,?)");
psmnt.setLong(1, userId);
fis = new FileInputStream(photoFile);
psmnt.setBinaryStream(2, (InputStream) fis, (int) (photoFile
.length()));
/*
* executeUpdate() method execute specified sql query. Here this
* query insert data and image from specified address.
*/
int s = psmnt.executeUpdate();
To insert an audio file in 3gp format , what will be the code using JDBC
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
代码应该完全相同:您需要确保您的音频文件足够小以适合该列(如果我没记错的话,mediumblob 是 16MBits 或大约)。数据库不关心它是音频还是图像数据。
为了讨论:
看起来公平吗?
The code should be exactly the same: you will need to make sure your audio file is small enough to fit into the column (mediumblob is 16MBits or there abouts if I recall correctly. The database doesn't care if its audio or image data.
For the sake of discussion:
Seems fair?