| Author |
Need Help!! Storing valuse in a database
|
menwa ms
Greenhorn
Joined: Nov 14, 2003
Posts: 12
|
|
hi.. 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\voice1.au), 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\voice1.au),, 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); } else { // save the new customer: try { //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/xxx.au"; //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 + ">"); } else { 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); pstmt.executeUpdate(); //comments.setText(userName+", added."); } else { String query = " INSERT INTO voice VALUES('"+vuserId+"', '"+vuserName+"', '"+vuserAddress+"', '"+vuserPhone+"', '"+vuserSex+"', '"+vuserDateBirth+"', ?) "; stat.executeUpdate(query); // } // vupdateTable(); } //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 thankx
|
 |
Dirk Schreckmann
Sheriff
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
|
|
|