This is the exception i am getting:
D:\Programming\Java\bin>JAVAC Demo.java
D:\Programming\Java\bin>java Demo
Error: Could not find or load main class Demo
D:\Programming\Java\bin>java -cp . Demo
Exception Born java.lang.ClassNotFoundException: oracle.jdbc.driver.OracleDrive
r
java.lang.ClassNotFoundException: oracle.jdbc.driver.OracleDriver
at java.net.URLClassLoader$1.run(URLClassLoader.java:366)
at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
at java.lang.ClassLoader.loadClass(ClassLoader.java:423)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
at java.lang.ClassLoader.loadClass(ClassLoader.java:356)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:188)
at Demo.main(Demo.java:14)
This is my code:
// Oracle Connection Program
import java.io.*;
import java.sql.*;
public class Demo
{
public static void main(String[] args)throws IOException, SQLException
{
String inq = " insert into login values(10,'shri')" ;
try
{
Class.forName("oracle.jdbc.driver.OracleDriver");
Connection con = DriverManager.getConnection("jdbc:oracle:thin:@127.0.0.1:1521:XE","system","admin");
Statement stmt = con.createStatement();
stmt.execute(inq);
con.close();
}
catch(Exception e)
{
System.out.println(" Exception Born "+e);
e.printStackTrace();
}
}
}
I have set the classpath to the odbc files in the oracle folder.. also copied them into the java bin folder. I've set classpath using the environment variable and also using cmd. But still the same error. I'm even connecting to the database using sql. Table is created. What is the problem? Any Hints?
-cp. You need the combination.