Why the result is Ljava.lang.string after i select multiple images & store the to MySql?
2 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
Alvindra Pratama
il 27 Mag 2016
Commentato: Alvindra Pratama
il 30 Mag 2016
I have chosen several images from a one folder, after i select 3 images & displayed them into edit text.
Edit text displayed like this :
D:/1.jpg
D:/2.jpg
D:/3.jpg
But at the table in gui which displayed that data after i save them to MySql, the data become Ljava.lang.string, not like edit text displayed above. How can i displayed the data like edit text above again?
2 Commenti
Geoff Hayes
il 27 Mag 2016
Alvindra - please show the code that you are using to extract the text from your control and the SQL statement that you have written to save the data to your database. Also, please confirm that the correct filenames (those from above) are being written to the database. If they are, then perhaps it is your SQL statement to get the data from your database that has been incorrectly formed. In either case, you need to show some of the code that you have written.
Risposta accettata
Geoff Hayes
il 29 Mag 2016
Alvindra - unfortunately, I can't run your code (I observe errors as soon as I run launch the GUI). I think the problem is that when you try to save the files to the database, you extract the filenames as
foto = get(handles.txtketfoto, 'String');
foto is most likely a cell array of strings and so you will have to treat it differently. How should this be written to your database? If you have n files, should you insert n records in to the database, one for each file? Or should you convert this cell array of strings to a single string where each filename is separated by a (for example) semi-colon?
5 Commenti
Geoff Hayes
il 29 Mag 2016
Do this after you have gotten the list of photos:
foto = get(handles.txtketfoto, 'String');
if strcmpi(class(foto),'cell')
myFilesAsString = '';
% etc.
else
myFilesAsString = foto;
end
datainsert(conn,'tbl_pca',{'id','nama','alamat','foto'},{id,nama,alamat,myFilesAsString});
Più risposte (0)
Vedere anche
Categorie
Scopri di più su String in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!