File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Beginning Java and the fly likes Need Help!! Storing valuse in a database Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Need Help!! Storing valuse in a database" Watch "Need Help!! Storing valuse in a database" New topic

Need Help!! Storing valuse in a database

menwa ms

Joined: Nov 14, 2003
Posts: 12
i have an application that works fine but i am getting this 1 error , and i really don't know how to solve it ..
here is my problem:
my application adds, deletes,updates,clear,search and play(to listen to the voice) users details with their voices as a .au path to a database... the users info will be added to the database and also his/her voice will be added ( i add the voice by writing the path eg: c:\java\, my problem is when i clear the fields and serach for the user i get in the text field of the voice something like 000FFDCEEDFFDCEE00<----- the hexadecimal or the unicode of the path ,, what i want is to get in the text field the path itself that i entered(c:\java\,, because when i click on the play button and i have the unicode in the text field it will not work...
here is my code:
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);
// save the new customer:
//1. take the customer's data and photo:
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 vTemplate = vtemplate.getText();
String vuserVoice=vvoice.getText();
File file = new File(vuserVoice);
int fileLength = (int)file.length();
String startPath = "/java/try/";

//3. Insert the data and photo into the database:
if(fileLength > 0)
if (!startPath.equals(vuserVoice))
System.out.println("startPath=<" + startPath + ">");
System.out.println("vuserVoice=<" + vuserVoice + ">");
System.out.println("The two paths were exactly the same");
fis = new FileInputStream(file);
String query = " INSERT INTO voice VALUES('"+vuserId+"', '"+ vuserName+ "', '"+ vuserAddress+ "', " +" '"+ vuserPhone+ "', '"+ vuserSex+ "', '"+ vuserDateBirth+ "', '"+ vTemplate+ "', ? ) ";
PreparedStatement pstmt = conn.prepareStatement(query);
pstmt.setBinaryStream(1, fis, fileLength);
//comments.setText(userName+", added.");
String query = " INSERT INTO voice VALUES('"+vuserId+"', '"+vuserName+"', '"+vuserAddress+"', '"+vuserPhone+"', '"+vuserSex+"', '"+vuserDateBirth+"', ?) ";
} //try
catch (Exception ee)
//The danger of putting creating the JOptionPane in here is that it will show the same message regardless of the error.
JOptionPane.showMessageDialog(null, "Customers ID already exits!!Please enter another ID","Invalid",JOptionPane.INFORMATION_MESSAGE);
System.out.println("Caught exception in add action: " + ee);
} //catch
} //if
}//add button

please can someone correct my code and help me
Dirk Schreckmann

Joined: Dec 10, 2001
Posts: 7023
my problem is ... i get in the text field of the voice something like 000FFDCEEDFFDCEE00
In your posted code example, I don't see a single line (saving one that's commented out) that is concerned with displaying something in a text field. Perhaps something is missing?
And are you sure that the beginner's forum is the right forum for this? Don't forget, for JDBC related issues, we have a JDBC forum, and for GUI related issues we have a Swing / JFC / AWT forum.

[How To Ask Good Questions] [JavaRanch FAQ Wiki] [JavaRanch Radio]
subject: Need Help!! Storing valuse in a database
Similar Threads
Qusetion for a project please help
Tab Problem!! PLZ HELP
how to store .au files? plz help
MS/Accessand unicode
Adding Scroll Bar