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
{
Class.forName("oracle.jdbc.driver.OracleDriver");


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


Connection conn =
DriverManager.getConnection(url,"stores","stores");

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


But it gives below error

Error: Could not find or load main class hello.world.app.HelloWorldApp

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

Regards,
Kamran
  • 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 hello.world.app.HelloWorldApp" 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

Legend

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