Reputation: 716
I have a question regarding MySQL. I am developing a swing application which has to be able to display list with documents stored in SQL database as BLOB files.I am updating my database with statments similar to this //
insert into materials_inf(name,material,subject,semester,teacher_first_name,teacher_last_name)
values('Physik Prufung',load_file('C:\Users\materials\1.sem_inf\Prufung_Physik'),'physiik','1','Sashka','Aleksandrova');
On the left side there are 8 list itemes. I want to send different queries for every semester when the user clicks on some of the them.
The result should be displayed in the right side. The result itself represents list of pdf and word documents. Is it possible to visualize this files and opening them with MS Word files by double clicking on any of list items in the swing interface? Screnneshot is attached.
http://s1333.photobucket.com/user/_spartacus/media/screen_zps208e5d16.jpg.html
Upvotes: 0
Views: 602
Reputation: 205805
Should I implement separate methods for every semester where the specific query for every semester is defined?
You may be able to use a single PreparedStatement
and pass it the parameters needed to query for a specific set of documents. Store the parameters in your ListModel
.
Addendum: Do I have to use PreparedStatement
in the valueChanged()
method in the list.
No, valueChanged()
will be called when the user clicks on the JList
. You would use a PreparedStatement
to populate your ListModel
, e.g. via the addElement()
method of DefaultListModel
. See How to Use Lists for examples.
Upvotes: 1
Reputation: 322
You can embed native applications using for example DJNativeSwing.
For sure you can embed IE, maybe that browser can use MS Word to render the documents... (see Wong Qil comment at http://java.dzone.com/news/dj-nativeswing-reloaded-jwebbr)
Upvotes: 0
Reputation: 691805
Yes, using Desktop.open():
Launches the associated application to open the file.
Of course, you'll have to save the blob to a temporary file, with the appropriate extension, before being able to open it.
This won't open the file on the right side of the app, though. I don't think it's easily possible to embed any kind of native application inside a Swing app. Maybe you'll find something for PDF, but as a user, I would prefer for PDF files to be opened in my preferred PDF viewer anyway, and same for all the other kinds of documents.
Upvotes: 1