Results 1 to 4 of 4
- 11-29-2011, 12:04 PM #1
Member
- Join Date
- Nov 2011
- Posts
- 1
- Rep Power
- 0
App freeze during MySQL connestion
Hi !
I need help with MySQL connection. I have this code:
This works fine and I get DB results. But when I added GUI and I call getTitleFromDB () method via button actionJava Code:public static void main(String[] args) throws SQLException { getTitleFromDB(); } public static void getTitleFromDB() { try { Class.forName("com.mysql.jdbc.Driver"); } catch(Exception e) { System.out.println("Driver error"); System.out.println(e.toString()); } try { Connection conn = DriverManager.getConnection("jdbc:mysql://localhost:3306/cz_lomnice", "adam", "1234"); Statement st = conn.createStatement(); ResultSet rs = st.executeQuery("SELECT title FROM lomnice_notams"); while (rs.next()) { System.out.println(rs.getString("title")); } } catch(Exception e) { System.out.println("DB connection error"); System.out.println(e.toString()); } }
it does not work in Win7 and app frozen (I found on line 17 above, button is pressed down and nothing work, even app closing is impossible). No error, no exception ! I tried to call method in SwingWorker and result is the same – no DB connection and no exception. I don't know where is problem. Is important to say that code above works in WinXP 32b completely (without and with GUI as well), in Win7 32b it works only without GUI (as I wrote above - with GUI app will freeze after button pressing). Does anybody know cause ?Java Code:private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) { getTitleFromDB (); }
Thanks Milan
- 11-29-2011, 01:22 PM #2
Moderator
- Join Date
- Apr 2009
- Posts
- 10,460
- Rep Power
- 16
Re: App freeze during MySQL connestion
I'm going to hazard a guess at MySQL and the JDBC driver.
I'd have a look at those two for possible problems on Win7...I do know there can be setup differences on a Win7 system, but don't ask me exactly what.
- 01-06-2012, 08:11 AM #3
Member
- Join Date
- Feb 2010
- Posts
- 80
- Rep Power
- 0
Re: App freeze during MySQL connestion
for now, create a separate thread for the connection so that the GUI would not be affected.
[why are you annoyed with my sig?]
- 01-06-2012, 09:34 AM #4
Moderator
- Join Date
- Apr 2009
- Posts
- 10,460
- Rep Power
- 16
Similar Threads
-
Freeze issue
By TomatoTom in forum Threads and SynchronizationReplies: 3Last Post: 05-09-2011, 12:13 PM -
Freeze cursor
By Gog in forum New To JavaReplies: 7Last Post: 01-14-2011, 10:29 PM -
Serial Comm freeze
By java_dude in forum NetworkingReplies: 3Last Post: 01-13-2011, 10:09 PM -
[SOLVED] How To Freeze Tab/s from JTabbedPane
By javanewbie in forum New To JavaReplies: 2Last Post: 06-10-2009, 09:42 AM -
freeze radioButton without disable them
By itaipee in forum AWT / SwingReplies: 5Last Post: 05-25-2009, 09:29 AM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks