Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 740183
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T08:29:10+00:00 2026-05-14T08:29:10+00:00

So I want to create a JDBC connection to MySQL server that is installed

  • 0

So I want to create a JDBC connection to MySQL server that is installed on my pc, here are the steps,
I installed MySQL with the username and password “root”, downloaded mysql-connector-java and from theere I coped the JAR “mysql-connector-java-5.1.12-bin” to “C:\Sun\SDK\jdk\jre\lib\ext”, I then added it as an external JAR in my project in eclipse, now in my class I have this code:

public void initialiseDatabase()
        {
            try { 
            // Load the Driver class. 
            Class.forName("com.mysql.jdbc.Driver"); 

            //Create the connection using the static getConnection method 
            databaseConnection = DriverManager.getConnection (databaseUrl+databaseName, 
                    dbUserName, dbPassword);
            sqlStatement = databaseConnection.createStatement();
            }
            catch (SQLException e) {e.printStackTrace();} 
            catch (Exception e) {e.printStackTrace();}
        }

(this is going to be psuedocode cause I am reading from a properties file and don’t want the one helping me reading through long lines of code from main to figure out all the variables),
where databaseUrl = “127.0.0.1”
dbUserName = “root”
dbPassword = “root”
databaseName = “MySQL” //this one I am not sure of, do I need to create it or is it set inherenrly?

now the MySQL server is up and running, but when I call the method initialiseDatabase the following exception is thrown:
“java.sql.SQLException: No suitable driver found for rootroot
at java.sql.DriverManager.getConnection(Unknown Source)
at java.sql.DriverManager.getConnection(Unknown Source)
at Proxy$JDBCConnection.initialiseDatabase(Proxy.java:721)”

when line 721 is:
sqlStatement = databaseConnection.createStatement();

Where have I gone wrong?

thanks

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-14T08:29:10+00:00Added an answer on May 14, 2026 at 8:29 am

    Your database url should look like this:

    jdbc:mysql://host:port/database
    

    Example, if you use localhost, the default port and a database named cachedb, your url would be:

    jdbc:mysql://localhost/cachedb
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to create a simple http proxy server that does some very basic
I want to create a function that performs a function passed by parameter on
I want to create my Rails application with MySQL, because I like it so
Note - this follows my question here: JDBC: Does the connection break if i
I want to create a subclass that extends the CallableStatement object. I want to
response.setContentType(text/html); PrintWriter out = response.getWriter(); Connection conn = null; String url = jdbc:mysql://localhost:3306/; String
I want to create SQL query that returns some values and one of those
I want to config tomcat server with mysql 5.1 community edition (on win server
I want to create a JDBC Realm for my web app. Since my users
i want create XML file here is my following code String fileName = jasstech.xml;

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.