title: database connection not working in jar, but does work in eclipse
body: <p>I have created a simple database in MYSQL, which I am trying to pull data from in a java program written in Eclipse.  When I run the program in eclipse, it pulls out the data fine, but when I export the program into a runnable JAR, it just won't work!!</p>
  
  <p>I have addedthe mysql connector by using the "add External Archive" feature in the build path, and have checked that its there by using </p>
  
  <pre><code>System.out.println("classpath = " + System.getProperty("java.class.path"));
  </code></pre>
  
  <p>which gives the results:
  classpath = C:\Users\Andy\workspace\test2\bin;C:\Users\Admin\Desktop\mysql-connector-java-5.1.16\mysql-connector-java-5.1.16-bin.jar</p>
  
  <p>I have also opened up the exported JAR file and have seen that the connector has been added.</p>
  
  <p>Here is the code that I am using:</p>
  
  <pre><code>import java.sql.Connection;
  import java.sql.DriverManager;
  import java.sql.ResultSet;
  import java.sql.ResultSetMetaData;
  import java.sql.Statement;
  
  import javax.swing.JOptionPane;
  
  
  
  public class test
  {
      public static void main(String args[])
  {
      try
      {
  
          Class.forName("com.mysql.jdbc.Driver").newInstance();
  
          Connection dbConn = DriverManager.getConnection("jdbc:mysql://localhost:3306/cambridge","root","P@ssw0rd");
          System.out.println("classpath = " + System.getProperty("java.class.path"));
  
          Statement stmt = dbConn.createStatement();
  
          String strSQL = "Select * from customer_details";
  
          ResultSet rs = stmt.executeQuery(strSQL);
  
          ResultSetMetaData rsmd = rs.getMetaData(); 
  
          int nCol = rsmd.getColumnCount();
  
          while(rs.next())
          {
              for(int col=1; col&lt;=nCol; col++)  
              {
                  System.out.print(rs.getString(col));
                  JOptionPane.showMessageDialog(null, rs.getString(col));
              }
  
              System.out.println();
          }
  
          System.out.println();
  
          dbConn.close();  
      }
      catch (Exception excp)
      {
          excp.printStackTrace();
      }
  }
  }
  </code></pre>
  
  <p>Thanks in advance for any help you can offer!!!</p>