| Author |
Qusetion for a project please help
|
menwa ms
Greenhorn
Joined: Nov 14, 2003
Posts: 12
|
|
hi ... i have this application that has a text field(voice) in which you enter the path of the .au file and it will be added in the database, and i also have asearch button that will search for that .au file with the info related to it but i get the unicode of the path(.au file)when i do the search which i don't want .. i want to get the path itself because when i get the unicode i can't play the .au file.(the field in the database that stores the .au files is of type text)..what i mean by unicode is for example when i enter c:\java\flute.au i get 00EEFDCDDFCEE0DDC of the path ) can some one tell me where the error is? how to correct the error? if(e.getSource()==vadd) { 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(); File file = new File(vuserVoice); int fileLength = (int)file.length(); if(fileLength > 0) { fis = new FileInputStream(file); String query = " INSERT INTO voice VALUES('"+vuserId+"', '"+vuserName+"', '"+vuserAddress+"', '"+vuserPhone+"', '"+vuserSex+"', '"+vuserDateBirth+"', '"+vuserTemplate+"', ? ) "; PreparedStatement pstmt = conn.prepareStatement(query); pstmt.setBinaryStream(1, fis, fileLength); pstmt.executeUpdate(); } else { String query = " INSERT INTO voice VALUES('"+vuserId+"', '"+vuserName+"', '"+vuserAddress+"', '"+vuserPhone+"', '"+vuserSex+"', '"+vuserDateBirth+"', '"+vuserTemplate+"',?) "; stat.executeUpdate(query); } /*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 add action: " + ev); } //catch }//else }//else and this is the code for the search: if(e.getSource() == vsearch) { try { String vuserId = vid.getText(); ResultSet adresults = stat.executeQuery("SELECT * FROM voice WHERE id = '"+vuserId+"' "); if(adresults.next()) { vname.setText(adresults.getString(2).trim()); vaddress.setText(adresults.getString(3).trim()); vphone.setText(adresults.getString(4).trim()); vsex.setText(adresults.getString(5).trim()); vdob.setText(adresults.getString(6).trim()); vtemplate.setText(adresults.getString(7).trim()); vvoice.setText(adresults.getString(8).trim()); }//if }//try catch(Exception vs) { System.out.println("Caught vdsearch exception: "+vs); }//catch }//adsearch please help..
|
 |
Dirk Schreckmann
Sheriff
Joined: Dec 10, 2001
Posts: 7023
|
|
|
Note that this is a duplicated post. The conversation is being continued over in the JDBC forum...
|
[How To Ask Good Questions] [JavaRanch FAQ Wiki] [JavaRanch Radio]
|
 |
 |
|
|
subject: Qusetion for a project please help
|
|
|