Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 10-17-2009, 12:25 AM
Member
 
Join Date: Dec 2008
Posts: 48
Rep Power: 0
ribbs2521 is on a distinguished road
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.
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","");

	}
Bookmark Post in Technorati
Reply With Quote
  #2 (permalink)  
Old 10-17-2009, 12:43 AM
Senior Member
 
Join Date: Jun 2008
Posts: 1,375
Rep Power: 3
masijade is on a distinguished road
Default
Well, maybe we could, if you showed us the url you used.
Bookmark Post in Technorati
Reply With Quote
  #3 (permalink)  
Old 10-17-2009, 03:52 AM
Member
 
Join Date: Dec 2008
Posts: 48
Rep Power: 0
ribbs2521 is on a distinguished road
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:
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)
Bookmark Post in Technorati
Reply With Quote
  #4 (permalink)  
Old 10-17-2009, 10:49 AM
Senior Member
 
Join Date: Jun 2008
Posts: 1,375
Rep Power: 3
masijade is on a distinguished road
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
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.
Bookmark Post in Technorati
Reply With Quote
  #5 (permalink)  
Old 10-17-2009, 04:18 PM
Member
 
Join Date: Dec 2008
Posts: 48
Rep Power: 0
ribbs2521 is on a distinguished road
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 ?.
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();
		}
	}
Bookmark Post in Technorati
Reply With Quote
  #6 (permalink)  
Old 10-17-2009, 04:32 PM
Senior Member
 
Join Date: Jun 2008
Posts: 1,375
Rep Power: 3
masijade is on a distinguished road
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?
Bookmark Post in Technorati
Reply With Quote
  #7 (permalink)  
Old 10-17-2009, 04:48 PM
Member
 
Join Date: Dec 2008
Posts: 48
Rep Power: 0
ribbs2521 is on a distinguished road
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.
Bookmark Post in Technorati
Reply With Quote
  #8 (permalink)  
Old 10-17-2009, 04:57 PM
Senior Member
 
Join Date: Jun 2008
Posts: 1,375
Rep Power: 3
masijade is on a distinguished road
Default
All I can say is, take a close look at the url used on that "other computer".
Bookmark Post in Technorati
Reply With Quote
  #9 (permalink)  
Old 10-19-2009, 02:53 PM
Member
 
Join Date: Dec 2008
Posts: 48
Rep Power: 0
ribbs2521 is on a distinguished road
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.
Bookmark Post in Technorati
Reply With Quote
  #10 (permalink)  
Old 10-19-2009, 04:00 PM
Member
 
Join Date: Aug 2009
Posts: 3
Rep Power: 0
sparlay_pk is on a distinguished road
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 06:43 AM.
Bookmark Post in Technorati
Reply With Quote
  #11 (permalink)  
Old 10-19-2009, 04:14 PM
PhHein's Avatar
Senior Member
 
Join Date: Apr 2009
Location: Germany
Posts: 444
Rep Power: 1
PhHein is on a distinguished road
Default
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
Bookmark Post in Technorati
Reply With Quote
  #12 (permalink)  
Old 10-20-2009, 06:45 AM
Member
 
Join Date: Aug 2009
Posts: 3
Rep Power: 0
sparlay_pk is on a distinguished road
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 06:48 AM.
Bookmark Post in Technorati
Reply With Quote
  #13 (permalink)  
Old 10-20-2009, 08:25 AM
Senior Member
 
Join Date: Jun 2008
Posts: 1,375
Rep Power: 3
masijade is on a distinguished road
Default
So start your own thread!
Bookmark Post in Technorati
Reply With Quote
  #14 (permalink)  
Old 10-21-2009, 08:18 AM
Senior Member
 
Join Date: Jun 2008
Posts: 1,375
Rep Power: 3
masijade is on a distinguished road
Default
Okay, and that is stopping you from starting your own thread, how?
Bookmark Post in Technorati
Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] im very new to java need help with taking years and turning it into days, hours, etc. mrnoahf New To Java 3 08-11-2009 01:18 AM
MySQL/JDBC Mysql query output thelinuxguy Advanced Java 4 02-13-2009 02:57 AM
sql connectivity prashant Database 2 12-27-2008 05:05 AM
Simple Project 4 or 5 Hours – Pay $100 billaaa777 Jobs Offered 0 08-30-2008 01:45 AM
ensure connectivity perdoname Database 1 04-22-2008 03:29 AM


All times are GMT +2. The time now is 03:42 PM.



VBulletin, Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2009, Crawlability, Inc.
Copyright ©2006 - 2007, www.java-forums.org