cannot find symbol DriverManager

S

satyashil

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
 
S

Sudsy

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;
 
C

Chris Smith

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
 
T

Tilman Bohn

In message <[email protected]>,
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
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,537
Members
45,020
Latest member
GenesisGai

Latest Threads

Top