?
Solved

Not able to connect to the database......

Posted on 2003-03-20
4
Medium Priority
?
149 Views
Last Modified: 2010-04-01
Hi,
   I have written a code in java to access database of server from client or to access database of the client from the server. I do not know where on the earth problem is ? every time I tried to run the code, it gives the following error :
   I have set classpath for classes12.zip file as c:\classes12.zip & tried following sample code on command line. My code is :

   import java.sql.*;
   import java.io.*;
   import java.lang.*;

 public class JdbcTest {
  public static void main(String[] args)throws      
   SQLException
       {
               //Class.forName("oracle.jdbc.driver.OracleDriver");
        DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver());
        Connection con = DriverManager.getConnection("jdbc:oracle:thin:@"+        "172.193.0.206:1521:nsp","scott","tiger");
        Statement stmt = con.createStatement();
        ResultSet rs = stmt.executeQuery("select ename from emp");
        while(rs.next())
          {
               System.out.println(rs.getString(1));
           }
        rs.close();
        stmt.close();
        con.close();
 }
}

( 172.193.0.206 is my IP)

I got following error:

C:\javaprog>javac JdbcTest.java
JdbcTest.java:10: cannot resolve symbol
symbol  : class OracleDriver
location: package driver
        DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver());
                                                           ^
1 error

  Although I have tried to find which of the mistake I did I could not figure out where I'm wrong ? I have set the classpath and the path correctly, the class files are on there places, and the extra path required is also provided, but.....
  Please help me to solve the problem and also tell me how can I connect my database to the client's/server's queries ?
  Thank you !
                                       Nilesh Parekh.
0
Comment
Question by:sangitasabale
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
4 Comments
 
LVL 14

Accepted Solution

by:
kennethxu earned 80 total points
ID: 8174654
try
javac -classpath c:\classes12.zip JdbcTest.java

also, make sure that the classes12.zip is not corrupted.
0
 
LVL 1

Expert Comment

by:umangjoshi
ID: 8179105
if the oracle server is not running on ur local computer or in local environment. it may be the problem of firewall.
0
 
LVL 35

Expert Comment

by:girionis
ID: 10060205
No comment has been added lately, so it's time to clean up this TA.
I will leave a recommendation in the Cleanup topic area that this question is:

- Points to kennethxu

Please leave any comments here within the next seven days.

PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!

girionis
EE Cleanup Volunteer
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

An introduction to the wonderful sport of Scam Baiting.  Learn how to help fight scammers by beating them at their own game. This great pass time helps the world, while providing an endless source of entertainment. Enjoy!
We are witnesses that everyone is saying that our children shouldn't "play" with a technology because it is dangerous. This article is going to prove that they are wrong.
NetCrunch network monitor is a highly extensive platform for network monitoring and alert generation. In this video you'll see a live demo of NetCrunch with most notable features explained in a walk-through manner. You'll also get to know the philos…
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…
Suggested Courses

765 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question