1

Iam new on using NetBeans 7.4 , i want to connect my java application to MYSQL , the application is desktop application . i have already install MYSQL workbench 5.2 and create database with one table . from NetBeans services on Databases i register MYSQL server , i enter these values : localhost : 127.0.0.1 , user : root and password : root.

from NetBeans

NetBeans ask me to set MYSQL command Path (Path to start command) i insert this path : C:\Program Files\MySQL\Connector ODBC 5.1\myodbc-installer.exe

from main class in java i saw from net how to set connection :

 Connection conn = null;
    try {
   conn = DriverManager.getConnection("jdbc:mysql://127.0.0.1:3306/sameer", "root","root");
  System.out.println("Connected database successfully...");
    } catch (Exception e) {
        System.out.println(e);
    }

but all time the exception will execute :

java.sql.SQLException: No suitable driver found for jdbc:mysql://127.0.0.1:3306/sameer

1 Answer 1

4

You need to include the mysql connector jar in your project.

If you haven't downloaded it yet you can find it here http://dev.mysql.com/downloads/connector/j/

Once you have downloaded it:

  • right click on the project
  • select Properties
  • select Libraries -> Add JAR/Folder
  • navigate your file system to select the jar you previously downloaded
  • save and it will run correctly
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.