Hi there, was wondering if anyone could help me.
I developed an application which works with MySQL using JDBC. It all works fine, but when I try to create a JAR file for my program, the code that uses mySQL seems not to be included into the jar file!
I added code for displaying messages in different parts of my code to find out at what point the problem is. It looks like the code that goes after line "Statement statement = connection.createStatement();" does not get included into the jar file.
Here is my main class code:
If I create and run the jar file, I get error message saying "here 1" and "here 2", but nothing at all happens after that.import java.sql.*; import javax.swing.JFrame; import javax.swing.JOptionPane; public class ResourceManagementApplication extends JFrame { private static MainFrame mainFrame; public static void main(String[] args) { Database db = new Database(); try { JOptionPane.showMessageDialog(null, "here 1", "There was an error!", JOptionPane.ERROR_MESSAGE); Connection connection = db.connect("jdbc:mysql://localhost:3306/", "root", "pw"); JOptionPane.showMessageDialog(null, "here 2", "There was an error!", JOptionPane.ERROR_MESSAGE); Statement statement = connection.createStatement(); JOptionPane.showMessageDialog(null, "here 3", "There was an error!", JOptionPane.ERROR_MESSAGE); statement.executeUpdate("USE ResourceManagementApplication;"); JOptionPane.showMessageDialog(null, "here 4", "There was an error!", JOptionPane.ERROR_MESSAGE); statement.close(); mainFrame = new MainFrame(connection); } catch( SQLException e ) { e.printStackTrace(); } catch( Exception e ) { e.printStackTrace(); } } }
Any ideas why that could be? I really need to get this working!