Results 1 to 1 of 1
- 08-07-2012, 08:01 PM #1
Member
- Join Date
- Aug 2012
- Posts
- 2
- Rep Power
- 0
JList....open file from database...
Hello everybody!!! i'm new here..i hope you can understand me what's my proble from many times!!!

I have created one program with Jlist database and JCombobox
in my db i have many tables where i can select about JCombobox
in table i have create id (autoincrement), nome, mp3, testo
ok!!! now i write you my code:
i have create create one class and this is code:
this code is ok!!!!Java Code:class QueryResult { private int id; public QueryResult(int id) { this.id = id; } public int getId() { return id; } // Custom toString() Method. public String toString() { return "ID=" + id; } }
then i have one method where i call class...and this is code:
i hope i write good so you can understand my problem!!! from many days!!!! i can't to go another code.....Java Code:public void listShow() { list.addMouseListener(new MouseAdapter() { public void mouseClicked(MouseEvent evt) { if (evt.getClickCount() == 2) { //HERE THERE IS PROBLEM!!!! show me error!!! but if insert //one number it's ok but the program select ony one song and text of there number...... QueryResult query = new QueryResult(list.getSelectedValue()); createPlayer(); try { Class.forName("org.gjt.mm.mysql.Driver"); } catch (Exception exc) { System.out.println("Errore - Driver jdbc non presente: "+ exc.getMessage()); } try { conn = DriverManager.getConnection("jdbc:mysql://localhost/basi?user=root&password=root"); stmt = conn.createStatement(); String sql = "SELECT base, testo FROM "+ combo2.getSelectedItem() + " where id="+ query.getId(); rs = stmt.executeQuery(sql); while (rs.next()) { removePreviousPlayer(); File file = new File(rs.getString("base")); MediaLocator mrl = new MediaLocator( file.toURI().toURL() ); player = Manager.createPlayer(mrl); player.addControllerListener( new EventHandler() ); player.start(); File f = new File(rs.getString("testo")); br = new BufferedReader(new FileReader(f)); textArea.setText(null); String st = ""; while((st=br.readLine()) != null){ if (!st.startsWith(">")) { textArea.append(st + "\n"); textArea.setFont(new Font("times new roman", Font.BOLD, 30)); } } } stmt.close(); conn.close(); } catch (Exception exc) { System.out.println("Errore: "+ exc.getMessage()); } } } }); }
help me please!!!!!
Similar Threads
-
Problem fetching data from database using JList
By LearnJava82 in forum New To JavaReplies: 3Last Post: 05-19-2012, 04:50 PM -
Help me populating JList from a txt file with a certain words
By labyrinthman in forum NetBeansReplies: 3Last Post: 05-16-2012, 09:57 PM -
Open a jar file with button swing and load this file.jar in a desktop pane
By lordhark in forum AWT / SwingReplies: 15Last Post: 02-16-2012, 03:43 PM -
Retrieving data from database using arrayList and display on JList
By mathidioticz in forum New To JavaReplies: 1Last Post: 01-25-2012, 05:10 PM -
Different Files Open in File -> Open Workspace
By mgm2010 in forum JCreatorReplies: 0Last Post: 04-11-2009, 02:14 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks