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 4087930
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T18:55:02+00:00 2026-05-20T18:55:02+00:00

I have installed Tomcat 6 and apache XAMPP on MAC OS. XAMPP includes MySQL.

  • 0

I have installed Tomcat 6 and apache XAMPP on MAC OS. XAMPP includes MySQL.

I turn on TOMCAT and XAMPP.

Then i try to connect with JDBC to MySQL.

public class main {

    public static void main(String[] args) {

        Connection conn = null;
        try
        {
            String userName = "root";
            String password = "";
            //<facility> is the name of the database i created
            String url = "jdbc:mysql://localhost/facility"; 
            Class.forName ("com.mysql.jdbc.Driver").newInstance ();
            conn = DriverManager.getConnection (url, userName, password);
            System.out.println ("Database connection established");
        }
        catch (Exception e)
        {
            System.out.println ("Cannot connect to database server");
        }

        finally
        {
            if (conn != null)
            {
                try
                {
                    conn.close ();
                    System.out.println ("Database connection terminated");
                }
                catch (Exception e) { /* ignore close errors */ }
            }
        }


    }
}

Well it gives me back “Cannot connect to database server”.

  • 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-20T18:55:03+00:00Added an answer on May 20, 2026 at 6:55 pm

    The problem is at the JDBC driver. You must include it to your classpath.

    You download it here: http://dev.mysql.com/downloads/connector/j/5.0.html

    Add the mysql-connector-java-5.1.15-bin.jar to your classpath

    Then it will work.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have installed a new tomcat server (5.5) and I get this exception: org.apache.jasper.JasperException:
I have Apache Geronimo installed with Tomcat. I am building a war file and
I have installed Apache Tomcat 6 as a Service in a Windows XP computer
I have Apache Tomcat 7 installed on Windows 7. I had its service in
I have installed Apache Solr with Tomcat and my /solr/admin is working fine. But
I have Tomcat 6.0.24 64 bit installed on two Windows Server 2008 boxes as
I have a Tomcat and PostgreSQL installed on a server. I'm having a connection
I have installed CherryPy 3.1.0,. Here is what happens when I try to run
I have installed WAMP. I am using Tomcat 6 to run my PHP scripts.
I have developed a JSF 2.0 application and tested it on Apache Tomcat 6.0.

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.