Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / First Aid / December 2004

Tip: Looking for answers? Try searching our database.

cannot find symbol DriverManager

Thread view: 
satyashil@exact-solutions.com - 16 Dec 2004 19:33 GMT
I am trying to execute following program:

import 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:oracle:thin:@" + 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
Chiron Paixos - 16 Dec 2004 22:44 GMT
How should the poor Java compiler know where to get a DriverManager?
Check your import-statements!
Perhaps some additional lines like
    import oracle.jdbc.driver.*;
    import java.sql.DriverManager;
will work miracles...

--
Never give up the fight for freedom - a fight which, though it may never end, is the most ennobling known to man. (R. Reagan)
Chris Smith - 16 Dec 2004 23:04 GMT
> How should the poor Java compiler know where to get a DriverManager?
> Check your import-statements!
> Perhaps some additional lines like
>     import oracle.jdbc.driver.*;
>     import java.sql.DriverManager;
> will work miracles...

Please avoid trial and error programming.  There is no need to import
the package of the driver class unless you intend to refer to it
directly in code by its simple name.  Only the import of DriverManager
is necessary.

Signature

www.designacourse.com
The Easiest Way To Train Anyone... Anywhere.

Chris Smith - Lead Software Developer/Technical Trainer
MindIQ Corporation



Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.