• 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

jdbc connection

 
Ranch Hand
Posts: 125
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi Everyone,

I have installed oracle 10g XE....and i have written a jdbc program to connect to the database....but my connection fails...I am not able to figure out where i have gone wrong.....

import java.sql.*;

class Demo
{

public static void main(String argv[])
{


try
{


Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");


// specify the ODBC data source's URL
//String url = "jdbc:oracle:thin:@localhost:orcl";

// connect
Connection con = DriverManager.getConnection("jdbc:odbc:XE","SYSTEM","saibaba");

System.out.println("Connected "+con.getClass());
}
catch (java.lang.Exception ex)
{

ex.printStackTrace();

}

}

}


Can anyone help me out???

Thanks in advance
Deepthi
 
Ranch Hand
Posts: 387
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi Deepthi,

-is your database really up and running
(there's a tutorial at http://download-uk.oracle.com/docs/cd/B25329_01/doc/admin.102/b25610/toc.htm)
-why do you use the jdbc/odbc driver instead of Oracle's Driver?
-did you get any error-message?
-you don't specify any portnumber (probably 1521)

Herman
 
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi Deepthi,

Is it throwing some exception...if it is then please let us know. that would be easier for us to find out a solution...

Abhishek
 
Ranch Hand
Posts: 884
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Deepthi,

I believe you're using Oracle's JDBC library. So the driver class name in your codes need to be changed. Follow this example and you should get it working.

Cheers!
 
I AM MIGHTY! Especially when I hold this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic