jdbc connection with oracle

Status
Not open for further replies.

vijay_ss2004

Broken In
hi folks i want to connect java application program with oracle 10g express edition . i tried hell lot of times but it showing classnotfound exception.i dont know which driver to use whether oci or thin driver.i also set classpath for oracle14.jar in environment varibles.i dont know wats the problem. can any of u help me regarding this.pls reply asap.thankx in advance folks.plssssssssssssssssssssssssssssss.....
 

ruturaj3

Journeyman
Post ur program. May be some thing wrong with ur coding.
chk this
*www.java-tips.org/other-api-tips/jdbc/how-to-connect-oracle-server-using-jdbc-4.html
 
Last edited:
OP
V

vijay_ss2004

Broken In
yeah this was my code can u find wats thw error is

import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.Statement;
import java.sql.DriverManager.*;
import java.sql.*;
public class simple
{
public static void main(String args[]) throws SQLException,ClassNotFoundException
{
try
{
//DriverManager.registerDriver(new oracle.jdbc.OracleDriver());
Class.forName("oracle.jdbc.driver.OracleDriver");
Connection con=DriverManager.getConnection("jdbc:eek:racle:eek:ci:mad:XE","system","vijay");
Statement st=con.createStatement();
ResultSet rs=st.executeQuery("select * from sample");
while(rs.next())
{
System.out.println(rs.getString(1));
System.out.println(rs.getInt(2));
}
con.close();
}
catch(SQLException e)
{
System.out.println(e.getMessage());
}
}
}

pls suggest me wat to do ....................thankx in advance ....

after executing the above program i m getting
C:\Program Files\Java\jdk1.5.0\bin>java -classpath . simple
Exception in thread "main" java.lang.ClassNotFoundException: oracle.jdbc.driver.
OracleDriver
at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:268)
at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:164)
at simple.main(simple.java:15)
pls help folks...................
 
Last edited:

Bandu

Journeyman
Why are you specifying the classpath when compiling the source?

Make it as your environment variable and make sure that your classes12.zip (or whatever) is in your classpath.
 

furious_gamer

Excessive happiness
ClassNotFoundException insense means that the compiler was unable to find the Oracle Driver file....Make sure u copy that file and paste it in ur classpath...
 
Status
Not open for further replies.
Top Bottom