File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes JDBC and Relational Databases and the fly likes How to use the getConnection() method? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC and Relational Databases
Bookmark "How to use the getConnection() method?" Watch "How to use the getConnection() method?" New topic

How to use the getConnection() method?

Jean Fore
Ranch Hand

Joined: Feb 23, 2006
Posts: 33
I am connecting to an SQL Server Database using JDBC Driver. I am using the following statements.

Connection con = null;
{ Class.forName("");
catch (ClassNotFoundException cf)

con = DriverManager.getConnectioncon = DriverManager.getConnection("jdbc dbc://localhost:1433/CCIntegration","CC","CC");
catch (SQLException sq)

Here I am concerend about the database URL part. My server is in the local machine and my database name is 'CCIntegration'. But when I run the above statement in the program, it says 'No suitable driver'. Can someone please help me with this basic thing?
Thank you in advance
stu derby
Ranch Hand

Joined: Dec 15, 2005
Posts: 333
"No suitable driver" ALWAYS means that none of the drivers that have been loaded (so far) recognize the DB URL as a URL they know how to process. therefore, getting this message ALWAYS means either:
  • the driver you think is loaded isn't really
  • the URL you think should work for your driver doesn't really

  • In your case, it's option number 2, your DB URL is wrong.

    Here's an example for the SQL Server 2000 driver:;en-us;313100

    Microsoft significantly changed the DB URL format for the SQL Server 2005 driver, see:
    Jean Fore
    Ranch Hand

    Joined: Feb 23, 2006
    Posts: 33
    Hi Stu,
    Thanks a lot for the response. I went to the site you gave me and tried whatever they have specified. (I am using SQLServer 2000). Even before using the getConnection method I am getting the exception. That means I am getting the exception in the class load. The try catch block for the
    throws the following exception.
    at Method)
    at java.lang.ClassLoader.loadClass(
    at sun.misc.Launcher$AppClassLoader.loadClass(
    at java.lang.ClassLoader.loadClass(
    at java.lang.ClassLoader.loadClassInternal(
    at java.lang.Class.forName0(Native Method)
    at java.lang.Class.forName(
    at UBDAO.getConnection(
    at UBDAO.main(
    Error Trace in getConnection() :

    Also I have set the class path variable properly. Do you have any idea what am I lacking in this ?
    [ May 19, 2006: Message edited by: Jean Fore ]
    Anwar Mian

    Joined: Jun 12, 2006
    Posts: 1
    Hello Jean:

    I had the same issue that you had. I tried the CLASSPATH way without any success. I'm using Websphere and the following is how it can be resolved.

    1. Right click the project to select the 'Properties'
    2. Highlight "Java Build Path"
    3. Select the "Labraries" tab
    4. Click on "Add External JARs"

    Then Add the following JAR files from where they are installed:


    Give it a try and it should work. The JVM is supposed to find the location of the JAR files from "CLASSPATH" system variable and load them but I guess in Websphere id does not do it that way.

    Good Luck!

    I agree. Here's the link:
    subject: How to use the getConnection() method?
    It's not a secret anymore!