Help coderanch get a
new server
by contributing to the fundraiser
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Devaka Cooray
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Tim Moores
  • Carey Brown
  • Mikalai Zaikin
Bartenders:
  • Lou Hamers
  • Piet Souris
  • Frits Walraven

database connectivity

 
Ranch Hand
Posts: 47
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi all
what are the steps for connecting my java class to a oracle database using type 4 driver

 
Ranch Hand
Posts: 874
Android VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Dipayan,

Check out Establishing Connection
 
dipayan chatterjee
Ranch Hand
Posts: 47
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi Balu

thanks a lot for the help i tried establishing a connection to my oracle 10g xe database

using the code:

import java.sql.*;

class Connn
{
public void get connection()
{
try{
Class.forName("oracle.jdbc.OracleDriver");
out.println("the driver has been loaded");
Connection con=DriverManager.getConnection("jdbc:oracle:thin:@acer:1521:xe","system","sys");
out.println("the connection has been established");
Statement stmt=con.createStatement();
int i=stmt.executeUpdate("insert into login values('"+s+"','"+s1+"')");
if(i==1)
{
out.println("data has been inserted into the database");
}
else
{
out.println("data could'nt be inserted into the database");
}
out.close();

}
catch(SQLException e)
{
out.println(e.getMessage());
}
catch(ClassNotFoundException f)
{
out.println(f);
}
}
}




but i am getting the following error

java.lang.ClassNotFoundException: oracle.jdbc.OracleDriver

what went wrong ? i have created the required tables
 
dipayan chatterjee
Ranch Hand
Posts: 47
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
sorry a line got skipped form the above posted code

here s and s1 are two strings
 
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
How are you adding the JDBC driver's jar file to the classpath?
 
dipayan chatterjee
Ranch Hand
Posts: 47
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
i have set the following classpath

CLASSPATH=.;C:\oracle\ora101\jdbc\lib\ojdbc14.jar;

do i need to include more jar files in my classpath
 
Balu Sadhasivam
Ranch Hand
Posts: 874
Android VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


i have set the following classpath

CLASSPATH=.;C:\oracle\ora101\jdbc\lib\ojdbc14.jar;

do i need to include more jar files in my classpath



That should work then. Check if the jar exists there and add it at the entry at the beginning of the CLASSPATH.
CLASSPATH=C:\oracle\ora101\jdbc\lib\ojdbc14.jar;.;

type CLASSPATH in the cmd to check if your classpath is set right

Can you tell us how do you set this classpath and run the application ? Using any IDE ?
 
dipayan chatterjee
Ranch Hand
Posts: 47
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi balu
the jar file ojdbc14 exsists i have also checked the classpath but the problelm still persists . i am using myeclipse 6 workbench
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic