Why the result is Ljava.lang.string after i select multiple images & store the to MySql?
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
Alvindra Pratama
am 27 Mai 2016
Kommentiert: Alvindra Pratama
am 30 Mai 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 Kommentare
Geoff Hayes
am 27 Mai 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.
Akzeptierte Antwort
Geoff Hayes
am 29 Mai 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 Kommentare
Geoff Hayes
am 29 Mai 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});
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Database Toolbox finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!