Results 1 to 3 of 3
  1. #1
    Godsent is offline Member
    Join Date
    Apr 2009
    Rep Power

    Default creating .jar with jdbc driver?

    Ok, i made swing GUI that works just fine and connects to SQL, and then i made it into .jar using this line:

    Java Code:
    "C:\Program Files\Java\jdk1.6.0_06\bin\jar.exe" cfm MyJar.jar Manifest.txt blist/
    So all files that is in blist folder will be in jar file, and they are. Everything seems to work, except connecting to SQL.

    Connecting looks like this:
    Java Code:
    	public void createConnection() {
    		try {
    			setParameters(0, "step 1...");
    			String serverName = "";
    			String mydatabase = "blist"; 
    			String url = "jdbc:mysql://" + serverName + "/" + mydatabase;
    			setParameters(40, "step 2...");
    			setParameters(60, "step 3...");
    			con = DriverManager.getConnection(url, "root", "");
    			stmt = con.createStatement();
    			setParameters(80, "step 4...");
    			connected = true;
    			setParameters(100, "step 5!");
    		} catch (Exception e) {
    I use setParameters void to set custom text for jLabel to find out where my application stops. And its step 2.

    So the problem must be with
    Java Code:
    Maybe i put it in .jar wrong, maybe i need specific line if using these jdbc?
    Please help

  2. #2
    markw8500's Avatar
    markw8500 is offline Senior Member
    Join Date
    Jul 2008
    Pennsylvania, USA
    Rep Power


    It sounds like your app can not find your driver... I compile all of my apps with netBeans and netBeans automatically creates a directory called "lib" and puts my driver in it... So you might want to try something like that...
    Who Cares... As Long As It Works...

  3. #3
    OrangeDog's Avatar
    OrangeDog is offline Senior Member
    Join Date
    Jan 2009
    Cambridge, UK
    Rep Power


    either copy the files from the driver's jar into yours, or add it to the classpath when you run the application
    Don't forget to mark threads as [SOLVED] and give reps to helpful posts.
    How To Ask Questions The Smart Way

Similar Threads

  1. DB2 JDBC Driver upgrade
    By sanssan in forum JDBC
    Replies: 2
    Last Post: 09-23-2008, 04:52 PM
  2. Jdbc Driver For Oracle
    By Swamipsn in forum New To Java
    Replies: 0
    Last Post: 08-14-2007, 04:31 AM
  3. JDBC Driver problem
    By Swamipsn in forum New To Java
    Replies: 3
    Last Post: 08-09-2007, 03:55 PM
  4. Help with JDBC driver
    By Daniel in forum JDBC
    Replies: 2
    Last Post: 07-03-2007, 08:16 PM

Posting Permissions

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