这个跟数据库没多大关系,取决于你的开发语言, 数据库取回字节流
try {
Class.forName("oracle.jdbc.driver.OracleDriver");
Connection con = DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:xe", "hr", "hr");
PreparedStatement ps = con.prepareStatement("select mp3 from audios where id = ?");
String id= request.getParameter("id");
ps.setString(1,id);
ResultSet rs = ps.executeQuery();
rs.next();
Blob b = rs.getBlob("mp3");
//改为相要的类型
response.setContentType("image/jpeg");
response.setContentLength((int) b.length());
InputStream is = b.getBinaryStream();
OutputStream os = response.getOutputStream();
byte buf[] = new byte[(int) b.length()];
is.read(buf);
os.write(buf);
os.close();
}
拿到字节流传给player还是生成文件,都是开发语言中。