This discussion is archived
12 Replies Latest reply: Dec 13, 2012 5:43 AM by 979522 RSS

JDBC connection problem

979522 Newbie
Currently Being Moderated
Hello.
I'm trying to establish a connection with Oracle DB (11g, JDK: 1.5)
Source code:
________________________________________________________________
import java.sql.*;
import oracle.jdbc.*;

class Conn {
  public static void main (String args []) throws Exception
  {

        Connection conn = DriverManager.getConnection
             ("jdbc:oracle:thin:@//localhost:1521/SERVER", "v", "QAZwsx111");  }
}
________________________________________________________________

javac Conn.java // succeeds
java Conn // throws Exception:
__________________________________________________________________
Exception in thread "main" java.lang.NoClassDefFoundError: Conn
Caused by: java.lang.ClassNotFoundException: Conn
__________________________________________________________________

I have tried many CLASSPATH definitions but nothing helps.
However, JDeveloper succeeds with connection (perhaps it uses its own libaries)

Help me please solve this, I'v stucked with it for two days.
Btw, sorry for the newbie post.

Legend

  • Correct Answers - 10 points
  • Helpful Answers - 5 points