• Post Reply Bookmark Topic Watch Topic
  • New Topic

jdbc connection

 
Padma Priya
Ranch Hand
Posts: 125
  • Mark post as helpful
  • send pies
  • 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 = "jdbcracle:thin:@localhostrcl";

// connect
Connection con = DriverManager.getConnection("jdbcdbc: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
 
Herman Schelti
Ranch Hand
Posts: 387
  • Mark post as helpful
  • send pies
  • 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
 
Abhishek Bharti
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • 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
 
Chengwei Lee
Ranch Hand
Posts: 884
  • Mark post as helpful
  • send pies
  • 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!
 
my overalls have superpowers - they repel people who think fashion is important. Tiny ad:
the new thread boost feature brings a LOT of attention to your favorite threads
https://coderanch.com/t/674455/Thread-Boost-feature
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!