Results 1 to 14 of 14
  1. #1
    ribbs2521 is offline Member
    Join Date
    Dec 2008
    Posts
    50
    Rep Power
    0

    Default MySQL connectivity (hours wasted)

    I have been searching through google for hours and tried everything I've found and still can't seem to get rid of this SQLException (No suitable driver found for mysql.//dbaddress/schema.......)

    Here is a snippet of my code, if anyone could help that would be great, I'm at a loss.
    Java Code:
    	public Connection getConnection(String url) throws SQLException, IOException, ClassNotFoundException
    	{
    
    		try
    		{
    			Class.forName("com.mysql.jdbc.Driver");
    		}
    		catch (ClassNotFoundException e)
    		{
                            System.out.println("Class Not Found");
                            System.exit(1);
    		}
    		
    		return DriverManager.getConnection(url, "BerlGeof","");
    
    	}

  2. #2
    masijade is offline Senior Member
    Join Date
    Jun 2008
    Posts
    2,571
    Rep Power
    8

    Default

    Well, maybe we could, if you showed us the url you used.

  3. #3
    ribbs2521 is offline Member
    Join Date
    Dec 2008
    Posts
    50
    Rep Power
    0

    Default

    Sorry, I didn't think the url mattered since the error was that the class wasn't found. I figured it was something with the classpath and/or a jar file not being found.

    jdbc:mysql://111.11.11.1/Schema_Name

    Here is the full error too:
    Java Code:
    java.sql.SQLException: No suitable driver found for jdbc:mysql://111.11.11.1/Sch
    ema_Nameuser=BerlGeof&password=
            at java.sql.DriverManager.getConnection(DriverManager.java:602)
            at java.sql.DriverManager.getConnection(DriverManager.java:207)
            at DB_Connection.getConnection(DB_Connection.java:74)
            at DB_Connection.<init>(DB_Connection.java:29)
            at EmployeeDash1.performComputation(EmployeeDash1.java:197)
            at EmployeeDash1.actionPerformed(EmployeeDash1.java:167)
            at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:19
    95)
            at javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.jav
    a:2318)
            at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel
    .java:387)
            at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:242
    )
            at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonL
    istener.java:236)
            at java.awt.Component.processMouseEvent(Component.java:6134)
            at javax.swing.JComponent.processMouseEvent(JComponent.java:3265)
            at java.awt.Component.processEvent(Component.java:5899)
            at java.awt.Container.processEvent(Container.java:2023)
            at java.awt.Component.dispatchEventImpl(Component.java:4501)
            at java.awt.Container.dispatchEventImpl(Container.java:2081)
            at java.awt.Component.dispatchEvent(Component.java:4331)
            at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4301
    )
            at java.awt.LightweightDispatcher.processMouseEvent(Container.java:3965)
    
            at java.awt.LightweightDispatcher.dispatchEvent(Container.java:3895)
            at java.awt.Container.dispatchEventImpl(Container.java:2067)
            at java.awt.Window.dispatchEventImpl(Window.java:2458)
            at java.awt.Component.dispatchEvent(Component.java:4331)
            at java.awt.EventQueue.dispatchEvent(EventQueue.java:599)
            at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThre
    ad.java:269)
            at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.
    java:184)
            at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThre
    ad.java:174)
            at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:169)
    
            at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:161)
    
            at java.awt.EventDispatchThread.run(EventDispatchThread.java:122)

  4. #4
    masijade is offline Senior Member
    Join Date
    Jun 2008
    Posts
    2,571
    Rep Power
    8

    Default

    No. The error was not ClassNotFound, it was "no suitable driver found". That usually means that you either typed the url wrong, or that you loaded one driver but tried to use another.

    Show the code with the url, as this
    Java Code:
    No suitable driver found for jdbc:mysql://111.11.11.1/Sch
    ema_Nameuser=BerlGeof&password=
    makes it look like you have a space in the table name, or that you forgot a ? between the table name and the user name.

  5. #5
    ribbs2521 is offline Member
    Join Date
    Dec 2008
    Posts
    50
    Rep Power
    0

    Default

    Bear with me, my code is not complete as my main concern is getting the driver to connect.

    Here is the method that is creating the connection object.
    Sorry for the break in the name, I copied the error from the CMD line which put the line breaks in there itself. I left my schema name in there this time and just removed the IP. The port hasn't always been in there, I added it last night in an attempt to fix this issue but no luck. Lastly, as you can see in my getConnection method that I'm not creating the full URL with username and pass, I'm using the three arg method. The method is compiling that, should there be a ? between username and the schema name? I can try sending the URL as one whole string including the username and pass with the ?.
    Java Code:
    	public void performComputation()
    	{
    		try
    		{
    			String strResults = null;
    			DB_Connection mysqlDB = new DB_Connection("jdbc:mysql://111.11.11.1:3306/dashboard_data");
    			//DataBase db = new DataBase();
    
    			//Get employee name, tokenize it into format that matches the report
    			StringTokenizer st = new StringTokenizer((String)jcbEmployee.getSelectedItem());
    			firstName = st.nextToken();
    			lastName = st.nextToken();
    			String employee = lastName + ", " + firstName;
    
    			System.out.println("Gathering data that matches employee " + employee);
    
    			sqlQuery1 = "Select Employee, OperationCode, TransactionQuantity From Resources " +
    						"where Employee = '" + employee + "'";
    
    			mysqlDB.showTablesInfo("person2");
    			//db.showTablesInfo(tableName);
    			System.out.println("\n---- Query 1 ----");
    			//strResults = db.createQuery(sqlQuery1, 3);
    			//jtResults.insert(strResults, 0);
    			//db.close();
    		}
    		catch (SQLException ex)
    		{
    			while (ex != null)
    			{
    				ex.printStackTrace();
    				ex = ex.getNextException();
    			}
    		}
    		catch (IOException ex)
    		{
    			ex.printStackTrace();
    		}
    		catch (Exception ex)
    		{
    			ex.printStackTrace();
    		}
    	}

  6. #6
    masijade is offline Senior Member
    Join Date
    Jun 2008
    Posts
    2,571
    Rep Power
    8

    Default

    The url is okay and the Class name is okay, so, is the mysql jarfile on the classpath when the program starts, or are you creating a classloader and adding the jarfile later?

  7. #7
    ribbs2521 is offline Member
    Join Date
    Dec 2008
    Posts
    50
    Rep Power
    0

    Default

    OK, I'm going to go insane. I am using a different computer than last night and it's working. I will have to try again on Monday when I have access to the other computer again. I will post what my classpath contents are when I get back to the other Computer.

  8. #8
    masijade is offline Senior Member
    Join Date
    Jun 2008
    Posts
    2,571
    Rep Power
    8

    Default

    All I can say is, take a close look at the url used on that "other computer".

  9. #9
    ribbs2521 is offline Member
    Join Date
    Dec 2008
    Posts
    50
    Rep Power
    0

    Default

    Interesting, it appears it was because I had the 5.0.8 jar file driver. The classpath was correct on the original PC but noticed it was 5.0.8 connector. I downloaded 5.1.0 and changed the classpath and now it works fine. I wouldn't think an old version would cause this issue I wasn't using any fancy SQL statements, just a SELECT * with no criteria.

  10. #10
    sparlay_pk is offline Member
    Join Date
    Aug 2009
    Posts
    4
    Rep Power
    0

    Default

    Plz help me i hav a problem with this code...
    error is class not found exception ... com.microsoft.sqlserver.jdbc.SQLServerDriver

    try
    {
    Class.forName("com.microsoft.sqlserver.jdbc.SQLSer verDriver");

    }

    catch(Exception ex)
    {
    ex.printStackTrace();
    }
    Last edited by sparlay_pk; 10-20-2009 at 05:43 AM.

  11. #11
    PhHein's Avatar
    PhHein is offline Senior Member
    Join Date
    Apr 2009
    Location
    Germany
    Posts
    1,430
    Rep Power
    6

    Default

    Java Code:
    Class.forName("com.microsoft.sqlserver.jdbc.SQLSer verDriver");
    The blank cannot be part of a class name in SQLServerDriver. If that was a typo, the driver is not on your calsspath. Add it.

    And why do you hijack a completely unrelated thread instead of starting a new one?
    Math problems? Call 1-800-[(10x)(13i)^2]-[sin(xy)/2.362x]
    The Ubiquitous Newbie Tips

  12. #12
    sparlay_pk is offline Member
    Join Date
    Aug 2009
    Posts
    4
    Rep Power
    0

    Default

    Plz help me i hav a problem with this code...
    error is class not found exception ... com.microsoft.sqlserver.jdbc.SQLServerDriver.


    try
    {
    Class.forName("com.microsoft.sqlserver.jdbc.SQLSer verDriver");
    }

    catch(Exception ex)
    {
    ex.printStackTrace();
    }

    The space you see in (SQLServ erDriver) is not the part of origional file, it's due to the editor.
    I have installed MS SQL 2005 ....
    Last edited by sparlay_pk; 10-20-2009 at 05:48 AM.

  13. #13
    masijade is offline Senior Member
    Join Date
    Jun 2008
    Posts
    2,571
    Rep Power
    8

    Default

    So start your own thread!

  14. #14
    masijade is offline Senior Member
    Join Date
    Jun 2008
    Posts
    2,571
    Rep Power
    8

    Default

    Okay, and that is stopping you from starting your own thread, how?

Similar Threads

  1. Replies: 3
    Last Post: 08-11-2009, 12:18 AM
  2. MySQL/JDBC Mysql query output
    By thelinuxguy in forum Advanced Java
    Replies: 4
    Last Post: 02-13-2009, 01:57 AM
  3. sql connectivity
    By prashant in forum JDBC
    Replies: 2
    Last Post: 12-27-2008, 04:05 AM
  4. Simple Project 4 or 5 Hours Pay $100
    By billaaa777 in forum Jobs Offered
    Replies: 0
    Last Post: 08-30-2008, 12:45 AM
  5. ensure connectivity
    By perdoname in forum JDBC
    Replies: 1
    Last Post: 04-22-2008, 02:29 AM

Posting Permissions

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