Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

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

Posted on 2003-03-20
4
Medium Priority
?
153 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
3 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

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Question has a verified solution.

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

How does storytelling impact the web? What goes into a great story on the web? And how can it be used for marketing purposes? All of these questions will be answered.
Herein one will find an aggregate of some of my experience building and deploying virtualization stacks both in standalone, clustered Hyper-V, clustered Hyper-V with a Scale-Out File Server (SOFS) backend, and Storage Spaces Direct (S2D).
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an anti-spam), the admin…
Whether it be Exchange Server Crash Issues, Dirty Shutdown Errors or Failed to mount error, Stellar Phoenix Mailbox Exchange Recovery has always got your back. With the help of its easy to understand user interface and 3 simple steps recovery proced…
Suggested Courses

580 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