Results 1 to 4 of 4
  1. #1
    meiilax is offline Member
    Join Date
    Nov 2011
    Posts
    1
    Rep Power
    0

    Question App freeze during MySQL connestion

    Hi !

    I need help with MySQL connection. I have this code:

    Java 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());
         }
     }
    This works fine and I get DB results. But when I added GUI and I call getTitleFromDB () method via button action

    Java Code:
    private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {                                         
          getTitleFromDB ();
    }
    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 ?

    Thanks Milan

  2. #2
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    12,015
    Rep Power
    20

    Default 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.

  3. #3
    clydedoris is offline Member
    Join Date
    Feb 2010
    Posts
    80
    Rep Power
    0

    Default 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?]

  4. #4
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    12,015
    Rep Power
    20

    Default Re: App freeze during MySQL connestion

    From the OP:
    "
    No error, no exception ! I tried to call method in SwingWorker and result is the same
    "

    What's with resurrecting old threads?
    Trying to advertise your site?

Similar Threads

  1. Freeze issue
    By TomatoTom in forum Threads and Synchronization
    Replies: 3
    Last Post: 05-09-2011, 12:13 PM
  2. Freeze cursor
    By Gog in forum New To Java
    Replies: 7
    Last Post: 01-14-2011, 10:29 PM
  3. Serial Comm freeze
    By java_dude in forum Networking
    Replies: 3
    Last Post: 01-13-2011, 10:09 PM
  4. [SOLVED] How To Freeze Tab/s from JTabbedPane
    By javanewbie in forum New To Java
    Replies: 2
    Last Post: 06-10-2009, 09:42 AM
  5. freeze radioButton without disable them
    By itaipee in forum AWT / Swing
    Replies: 5
    Last Post: 05-25-2009, 09:29 AM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •