I am new to database handling. I am creating a karaoke player in Java, where I need to have a database. I don’t have to get material (sound and text file) directly from hard disk, but I want a database (SQL Server, Oracle, etc) to store them, so that I can have an object, which can refer/point to them. Is it possible??
public class SoundPlayer extends JComponent
{
String windowName;
Clip clip;Clip clip2;
public static void main(String[] args) throws UnsupportedAudioFileException,
IOException, LineUnavailableException, InterruptedException
{
JFrame f=new JFrame("hh");
f.getContentPane();
f.pack();
f.setVisible(true);
}
private String String;
public SoundPlayer(File file) throws UnsupportedAudioFileException, IOException, LineUnavailableException, InterruptedException {
AudioInputStream ain=AudioSystem.getAudioInputStream(file);
try
{
DataLine.Info info=new DataLine.Info(Clip.class,ain.getFormat());
AudioFormat inFormat = ain.getFormat();
clip=(Clip) AudioSystem.getLine(info);
//rest code
The object should be available in my program, so that I can access it.
Yes, it’s possible (look at BLOB support in Oracle and JDBC), but the generally accepted way to do this is to store the files in the file system, and then just store the path to the file in the database.
As it looks like you’re writing a desktop application, you have to think about how to access this information. If this is a single-user application with a local database, then you’ll be fine with files in the local file system and paths in the database.
If this is a multi-user system with a shared database, then you’ll probably want to create a server that handles requests from the desktop app. It can look up the path in the database, get the file, and return it to the desktop app.