cannot find symbol DriverManager

Discussion in 'Java' started by satyashil@exact-solutions.com, Dec 16, 2004.

  1. Guest

    I am trying to execute following program:

    mport java.util.Properties;
    import java.util.ResourceBundle;
    import java.util.Enumeration;
    import java.util.ArrayList;
    import java.io.IOException;
    import java.sql.CallableStatement;
    import java.sql.Statement;
    import java.sql.Connection;
    import java.sql.Types;
    import java.sql.ResultSet;
    import java.sql.SQLException;

    class OraTest
    {
    OraTest()
    {
    Connection connection = null;
    try
    {
    // Load the JDBC driver
    String driverName = "oracle.jdbc.driver.OracleDriver";
    Class.forName(driverName);

    // Create a connection to the database
    String serverName = "127.0.0.1";
    String portNumber = "1521";
    String sid = "ram";
    String url = "jdbc:eek:racle:thin:mad:" + serverName + ":" + portNumber +
    ":" + sid;
    String username = "scott";
    String password = "tiger";
    connection = DriverManager.getConnection(url, username, password);

    }
    catch (ClassNotFoundException e)
    {
    // Could not find the database driver
    }
    catch (SQLException e)
    {
    // Could not connect to the database
    }
    }
    public static void main(String[] args)
    {
    System.out.println("Hello World!");
    }
    }

    ---------------------------------------------------------------
    I am getting following error:

    OraTest.java:31: cannot find symbol
    symbol : variable DriverManager
    location: class OraTest
    connection = DriverManager.getConnection(url,
    username,
    password);
    ^
    1 error


    I have added classpath also. Here is my classpath:
    C:\oracle\ora81\jdbc\lib\classes12.zip;D:\oracle\jdbc\lib\classes12.zip
    Please guide..

    Regards
    Satya
     
    , Dec 16, 2004
    #1
    1. Advertising

  2. Sudsy Guest

    wrote:
    [sic]
    > mport java.util.Properties;
    > import java.util.ResourceBundle;
    > import java.util.Enumeration;
    > import java.util.ArrayList;
    > import java.io.IOException;
    > import java.sql.CallableStatement;
    > import java.sql.Statement;
    > import java.sql.Connection;
    > import java.sql.Types;
    > import java.sql.ResultSet;
    > import java.sql.SQLException;

    <snip>
    import java.sql.DriverManager;
     
    Sudsy, Dec 16, 2004
    #2
    1. Advertising

  3. Chris Smith Guest

    <> wrote:

    > mport java.util.Properties;
    > import java.util.ResourceBundle;
    > import java.util.Enumeration;
    > import java.util.ArrayList;
    > import java.io.IOException;
    > import java.sql.CallableStatement;
    > import java.sql.Statement;
    > import java.sql.Connection;
    > import java.sql.Types;
    > import java.sql.ResultSet;
    > import java.sql.SQLException;


    > ---------------------------------------------------------------
    > I am getting following error:
    >
    > OraTest.java:31: cannot find symbol
    > symbol : variable DriverManager
    > location: class OraTest


    You're missing an import:

    import java.sql.DriverManager;

    or, of course, write:

    connection = java.sql.DriverManager.getConnection(
    url, username, password);
    --
    www.designacourse.com
    The Easiest Way To Train Anyone... Anywhere.

    Chris Smith - Lead Software Developer/Technical Trainer
    MindIQ Corporation
     
    Chris Smith, Dec 16, 2004
    #3
  4. Guest

    :) .......Thanks
     
    , Dec 16, 2004
    #4
  5. Guest

    :) ........thanks
     
    , Dec 16, 2004
    #5
  6. Tilman Bohn Guest

    In message <>,
    wrote on 16 Dec 2004 11:29:19 -0800:

    > OraTest.java:31: cannot find symbol
    > symbol : variable DriverManager


    Either qualify the class name with the full package, or add a
    suitable import statement. (You're already importing classes from
    the same package.)

    Cheers, Tilman

    --
    `Boy, life takes a long time to live...' -- Steven Wright
     
    Tilman Bohn, Dec 16, 2004
    #6
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Danny
    Replies:
    1
    Views:
    4,685
    Andrew Thompson
    May 26, 2004
  2. Replies:
    3
    Views:
    9,609
    Manish
    Jun 3, 2005
  3. luch
    Replies:
    5
    Views:
    6,350
  4. asit

    DriverManager in JDBC

    asit, Jul 8, 2009, in forum: Java
    Replies:
    6
    Views:
    750
    Roedy Green
    Jul 10, 2009
  5. Replies:
    6
    Views:
    1,821
Loading...

Share This Page