This discussion is archived
1 Reply Latest reply: Apr 3, 2013 12:16 PM by 1000888 RSS

Error While connectivity of java with oracle

Kam_oracle_apex Newbie
Currently Being Moderated
Dear Friends,

I wrote a code to connect java with oracle. I am using orace 11g XE and netbeans.

Code is:

import java.sql.*;

public class TestDBOracle {

public static void main(String[] args)
throws ClassNotFoundException, SQLException

String url = "jdbc:oracle:thin:@localhost:1521:xe";

Connection conn =

Statement stmt = conn.createStatement();
ResultSet rset =
stmt.executeQuery("select BANNER from SYS.V_$VERSION");
while ( {
System.out.println (rset.getString(1));
System.out.println ("Ok.");

But it gives below error

Error: Could not find or load main class

Can any1 helo me in this regard. I will be thankful

  • 1. Re: Error While connectivity of java with oracle
    1000888 Newbie
    Currently Being Moderated
    You are saying that "Error: Could not find or load main class" you Are getting but you did not create thos class any where.lLets consider you compiled your program.
    And not able to run that means your java classpath not set.
    run set classpath=.;<"Java path up to bin">;%classpath%.
    Then your program will run.

    Rinkoo Kushwah


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