0

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

enter image description here

3 Answers 3

1

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.

Sign up to request clarification or add additional context in comments.

1 Comment

All right but how can i add the result set to the right panel? Should i implement separate methods for every semester where the the specific query for every semester is defined? I want it to be displayed as table. Any ideas? Thank you!
1

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.

1 Comment

Thank you for the answer! To be honest i really dont know where to apply this PreparedStatment. Do I have to use it in the valueChanged() method in the list. Sorry if the questions I ask are dumb but i am not so familiar with this kind of stuffs. I will really appreciate it if someone can post some code that can help me for my problem.
0

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)

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.