Firstly I realise that this is a familiar question, it seems to pop up here all the time. Secondly, I am NOT storing the audio as a BLOB, I am storing the path to it!
Basically, I know I need to manipulate the result set but what I cant seem to get my head around is how to get the audio from the result set. I have done this with images, but not yet with audio. Any help would be much appreciated. Below is the code I used to get my image from the DB.
ResultSet rs = stmt.executeQuery(query);
String images = "";
while (rs.next()) {
images = rs.getString("path");
System.out.println(images + "\n");
System.out.println("TESTING - READING IMAGE");
BufferedImage img = ImageIO.read(new File(images));
System.out.println("img = " + images);
imagelabel = new JLabel(new ImageIcon(img));
imagelabel.setPreferredSize(new Dimension(200, 200));
imageframe = new JFrame();
imageframe.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
imageframe.setSize(200,200);
imageframe.add(imagelabel);
imageframe.setVisible(true);
You basically use the Java Sound Api. Read Accessing Audio System Resources to read the audio file and read Playing Back Audio to play it.
NOTE: Didn’t test this but since no one has answered yet, I wanted to show you where to look for.