Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

Help !!how to store .au files using java

Posted on 2003-11-03
5
625 Views
Last Modified: 2010-03-31

hi i have this application that i wrote in which i want it to (add,search,delete,paly,stop) a .au or .wav file into a database,,

i will show you the code i wrote , but this is not the complete application cause it is quite long ,, i will show the important part..
the code includes an add button,paly and stop button and the delete..it will add the users info such as (id, name ,phone, address etc) with an .au file (which is the voice of this user ) into the datbase, in which i included a text field called vvoice so the user will enter the path of the .au file, the problem is i don't know how to add the .au file (i don't know the code for it )
i also want to know how to search for it if there was an existing .au file in the database..
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.table.*;
import java.sql.*;
import java.io.*;
import javax.swing.JPanel;
import java.applet.*;
import sun.audio.*;
import java.net.*;
import java.text.*;



class VoiceMethods extends JFrame implements ActionListener
{
private File fileName;
AudioStream voice;
VoiceMethods voice;
Connection conn;
Statement stat;
String dsnName, userStatus;
String appTable = "CUSTOMER";
Container c = getContentPane();
JTextField vid,vname,vaddress,vphone,vsex,vdob,vtemplate,vvoice;
JButton vsearch,vupdate,vclear,vadd,vdelete,vclose,vplay,vstop;
JPanel vbackPanel, vinputPanel, vmiddlePanel, vbuttonPanel1, vbuttonPanel2;
}
void makeGUI()
{
c.setLayout(new BorderLayout());
voicePanel= new JPanel(new BorderLayout());
vinputPanel = new JPanel(new GridLayout(4, 4));
vid = new JTextField(20);
vname = new JTextField(20);
vaddress = new JTextField(20);
vphone = new JTextField(20);
vsex = new JTextField(20);
vdob = new JTextField(20);
vtemplate = new JTextField(20);
vvoice= new JTextField(20);

vinputPanel.add(new JLabel("ID", JLabel.CENTER));
vinputPanel.add(vid);
vinputPanel.add(new JLabel("Name", JLabel.CENTER));
vinputPanel.add(vname);
vinputPanel.add(new JLabel("Address", JLabel.CENTER));
vinputPanel.add(vaddress);
vinputPanel.add(new JLabel("Phone", JLabel.CENTER));
vinputPanel.add(vphone);
vinputPanel.add(new JLabel("Sex", JLabel.CENTER));
vinputPanel.add(vsex);
vinputPanel.add(new JLabel("Date Of Birth", JLabel.CENTER));
vinputPanel.add(vdob);
vinputPanel.add(new JLabel("Template ", JLabel.CENTER));
vinputPanel.add(vtemplate);
vinputPanel.add(new JLabel("Voice ", JLabel.CENTER));
vinputPanel.add(vvoice);

voicePanel.add(vinputPanel, BorderLayout.NORTH);

//The buttons section:
vbackPanel = new JPanel();
vmiddlePanel = new JPanel(new BorderLayout());
vbuttonPanel1 = new JPanel();
vbuttonPanel2 = new JPanel();
vsearch = new JButton("SEARCH");
vupdate = new JButton("UPDATE");
vclear = new JButton("CLEAR");
vadd = new JButton("ADD");
vdelete = new JButton("DELETE");
vclose = new JButton("EXIT");
vplay = new JButton("PLAY");
vstop = new JButton("STOP");
}
public void actionPerformed(ActionEvent e)
{
if(e.getSource()==vplay)
{
try{
//file=fileName.getPath();
InputStream in = new FileInputStream(fileName.getPath());
AudioStream as = new AudioStream(in);
voice = as;
AudioPlayer.player.start(as);
voice = as;
}//try
catch(IOException ii){}
}//else if
//------------------------------------------------------------------------------------------------------------
else if(e.getSource()==vstop)
{

AudioPlayer.player.stop(voice);
}//else if
//------------------------------------------------------------------------------------------------------------
else if(e.getSource()==vadd)
{

//User has not populated all the input fields.

if(vname.getText().equals("")|| vaddress.getText().equals("")|| vphone.getText().equals("")|| vsex.getText().equals("")|| vdob.getText().equals("")|| vtemplate.getText().equals("")|| vvoice.getText().equals(""))
{
JOptionPane.showMessageDialog(null, "Please fill in all the fields","Missing Fields",JOptionPane.INFORMATION_MESSAGE);
}//if
else
{
// save the new customer:

try
{
//1. take the customer's data:

int vuserId = Integer.parseInt(vid.getText());
String vuserName = vname.getText();
String vuserAddress = vaddress.getText();
String vuserPhone = vphone.getText();
String vuserSex = vsex.getText();
String vuserDateBirth = vdob.getText();
String vuserTemplate = vtemplate.getText();
String vuserVoice=vvoice.getText();

String query = " INSERT INTO voice VALUES('"+vuserId+"', '"+vuserName+"', '"+vuserAddress+"', '"+vuserPhone+"', '"+vuserSex+"', '"+vuserDateBirth+"', '"+vuserTemplate+"', '"+vuserVoice+"') ";
stat.executeUpdate(query);
vupdateTable();

} //try
catch (Exception ev)
{
System.out.println("Caught exception in update action: " + ev);
} //catch
}//else
}//else if
}

the table in my database is called voice which includes the same fields that i have in my app..(can someone also tell me if the code for the paly and stop button is correct)..

Thankx

0
Comment
Question by:nawaray82
  • 2
5 Comments
 
LVL 20

Accepted Solution

by:
Venabili earned 25 total points
ID: 9735788
For working with the database you should use JDBC.
http://java.sun.com/docs/books/tutorial/jdbc/TOC.html

How you compare two files?  If you want to compare the actual files - well this will take too much time
0
 
LVL 2

Expert Comment

by:Nata
ID: 9889411
nawray82;
 
You seem to be having some difficulty with understanding how Experts Exchange works, in that you have closed none of the eight questions you've asked. Please see the following:

 
Then please take care of the following questions:
http://www.experts-exchange.com/Q_20757688.html
http://www.experts-exchange.com/Q_20758171.html 
http://www.experts-exchange.com/Q_20758703.html
http://www.experts-exchange.com/Q_20763887.html
http://www.experts-exchange.com/Q_20764917.html
http://www.experts-exchange.com/Q_20774538.html
http://www.experts-exchange.com/Q_20779421.html
http://www.experts-exchange.com/Q_20785878.html
 
This is a gentle note; if you don't close these questions in short order, your ability to participate at Experts Exchange could be in jeopardy.
 
Nata
EE Page Editor
0
 
LVL 20

Expert Comment

by:Venabili
ID: 9914618
I disagree. If the Asker needed more information than I gave them, they could ask further...

Venabili
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
servlet doXXX methods 3 62
Custom Java Application connects to database: Which one of the 20? 4 35
eclipse console opening separately 2 29
learn programming 8 42
Are you developing a Java application and want to create Excel Spreadsheets? You have come to the right place, this article will describe how you can create Excel Spreadsheets from a Java Application. For the purposes of this article, I will be u…
Introduction This article is the first of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article explains our test automation goals. Then rationale is given for the tools we use to a…
Viewers learn about the “for” loop and how it works in Java. By comparing it to the while loop learned before, viewers can make the transition easily. You will learn about the formatting of the for loop as we write a program that prints even numbers…
Viewers learn how to read error messages and identify possible mistakes that could cause hours of frustration. Coding is as much about debugging your code as it is about writing it. Define Error Message: Line Numbers: Type of Error: Break Down…

829 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question