• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

oracle 8i connectivity

 
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
can anyone tell me how to connect oracle 8i using jdbc.i want to know the driver that is used.feel free to mail me.
thanks in advance
 
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
First of all find your drivers, mine were located in <DRIVE>:\Oracle\Ora81\jdbc\lib\classes12.zip, and add them to your classpath so you can reference them in the import statements
Next, register the driver using the statement using:
DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver());
Then define the connection by using:
String url = jdbc racle:TYPE:@DATABASE_NAME;
/**Replace TYPE with either 'thin' or 'oci8' depending on the driver that you're wanting to use. They both have different pro's and con's depending on what you are using them for. You can find more info at oracle.com. Replace the database name with the name of the database in the TSNNAMES file that you need to access. If you need to access the database remotely, then replace it with url(or ip) :port:SID. Ex. 127.0.0.1:1521:MYDATABASE (1521 is the default port for Oracle) and next.....*/
String username = your_username;
String password = your_password;
/**that one's easy, they are just your username and password for that database, then finally....*/
Connection con = DriverManager.getConnection(url, username, password);
/**this creates the connection object and you are now connected to the database of your choice*/
After you have the connection you need to create your statement object:
Statement stmt = con.createStatement();
Then use these to execute the SQL statements:
stmt.executeUpdate(Your_Update_String);
or stmt.execute(Your_String);
or stmt.executeQuery(Your_Query_String);

JDBC commits the data automaticaly so if you need or want to commit transaction manually then you can set the auto commit to false before you create the statement using:
con.setAutoCommit(false)
and after your transaction is complete you can commit it by using con.commit() and if the SQL statement fails you can place a con.rollback() in your catch statement to roll back any partial changes to the data.
Hope that helps out.
Disabled smiles in this post
[This message has been edited by Desai Sandeep (edited November 30, 2001).]
 
Rob Lyon
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Sorry I didn't realize you have to turn off smiles. Here's what the smiles messed up:
String url = jdbc:oracle:TYPE:@DATABASE_NAME;
****and****
url(or ip):port:SID
 
Ranch Hand
Posts: 1157
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Ron,
JavaRanch provides you with a feature to edit your posts and make changes to it.If you click on the third icon (just at the top of the post), you will get a option to Disable the Smiles.
Regards,
Sandeep
[This message has been edited by Desai Sandeep (edited November 30, 2001).]
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic