J2EE project has connection problem to mysql

I have an urgent problem. I accidently deleted my Java installation. Not a major problem or so I thought. This also included my tomcat install and eclipse install.

So I began the process of the reinstalling. The problem here though is that when I loaded an application I was working on at work. It wont allow me to connect to the MySQL database. This is a serious problem. What happened or changed that could have cause this. Would a new version to Tomcat/Java/J2EE/Eclipse be causing this problem?

Please help
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Post what kind of error you see.
bhessionAuthor Commented:
java.sql.SQLException: No suitable driver found for jdbc:mysql://localhost:3306/myapp
bhessionAuthor Commented:
This is very frustrating as I have nothing changed
Exploring SQL Server 2016: Fundamentals

Learn the fundamentals of Microsoft SQL Server, a relational database management system that stores and retrieves data when requested by other software applications.

Still you obviouslky have to check if you have the appropiate .jkar with mysql driver - believe it is named something like ConnectJ - easily can be found accessible to your web application - say in WEB-INF/lib
bhessionAuthor Commented:
its in there and its in the build path. So there is no reason why it shouldnt work
This is strange.

Check the name of the class of the driver - if it is in the jar file the way you call it in the code.
Myabe you previously had some older version in the code and now it changed the name
and now you have newer version jar.

You can alos put it into general lib under tomcat home folder
do you have the driver class name explicitly in the code, or you set up some parameters thriugh tomcat (like in xml,etc.)  
bhessionAuthor Commented:
What you mean with the below?
Check the name of the class of the driver - if it is in the jar file the way you call it in the code.

Also how do you do this?
You can alos put it into general lib under tomcat home folder

Here is my connect code

Connection con = null;
	Statement stmt = null;
	PreparedStatement ps = null;
	ResultSet rs = null;
	String dbURL = "jdbc:mysql://localhost:3306/myapp";
	String username = "username";
	String password = "password";
public void Connect1()
			con = DriverManager.getConnection(dbURL, username, password);
		 catch (Exception e) {
						.println("An error has occurred during the connection phase! Did you upload your Oracle Drivers?");

Open in new window


No, you need to either setup it with connection pool aet up in Tomcat, or you need to have it in the code
either with explicit import startements or in
Class.forName(....) statement which should be called before DriverManager

On the other hand this class name/path which is refrreed in the connection pooling setup of in Class.forname() statement
should be present in the jar
To check that you copy the .jar to the file ending with .zip and open it with Winzip or any other windows
zipping program and check, say if you have

 Class.forName ("oracle.jdbc.driver.OracleDriver")

then in your jar you would need to have class


I of course used oracle as a handy example

For my SQL you 'd have different path and class name of course


bhessionAuthor Commented:
This was the line or at least the mysql equiv, strange it worked with my earlier installation for months, suddenly a problem with my new installation. Truely baffling. Thank you so much for your help!

 Class.forName ("oracle.jdbc.driver.OracleDriver")

That is how I was recently connecting to MySQL with driver class name


jar name is :

 import java.sql.Connection;
 import java.sql.DriverManager;
 import java.sql.ResultSet;
 import java.sql.Statement;
 public class TestMySql {
      public static void main(String[] args) {
   System.out.println("MySQL Connect Example.");
   Connection conn = null;
   String url = "jdbc:mysql://server_name:3306/";
   String dbName = "dbname";
   String driver = "com.mysql.jdbc.Driver";
   String userName = "user";
   String password = "password";
   try {
   conn = DriverManager.getConnection(url+dbName,userName,password);
       Statement stmt = conn.createStatement();
       ResultSet rs = stmt.executeQuery("select * from java_mysql.test_table");
           String s = rs.getString("a");
           float f = rs.getFloat("b");
           System.out.println("a: " + s + " b: " + f);
   System.out.println("Connected to the database");
   System.out.println("Disconnected from database");
   } catch (Exception e) {

Open in new window

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
bhessionAuthor Commented:
Excellent diagnosis. Thanks again
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Java EE

From novice to tech pro — start learning today.