• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

jdbc connectivity

 
arjun gaur
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hey!! i have ORACLE EXPRESS EDITION 10G (10.2)
i want to connect to it using JDBC.
can you tell me what and from where should i download the necessary jdbc driver..do give me the link.
and also how should i connect to it.i mean what code to write,and also how to specify the path of data source name .and changes to be made to the path and classpath.
Thanks
 
Ulf Dittmer
Rancher
Posts: 42969
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can find those easily. A search term that suggests itself would be "oracle express 10g jdbc driver". The results you get for that will also point you to documentation. Since you already have JDBC code, you only need to change the driver class name and the connection URL.

The PATH is not used for Java classes, so nothing changes about that. The driver comes as a jar file, so you will need to add that to the classpath.
 
arjun gaur
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
ohk thanks i got it,but confused which one to download.oracle website is showing several different drivers for different platforms:


classes12.jar (1,621,582 bytes) - for use with JDK 1.2 and JDK 1.3
classes12_g.jar (2,070,298 bytes) - same as classes12.jar, except that classes were compiled with "javac -g" and contain some tracing information.
classes12dms.jar (1,629,454 bytes) - same as classes12.jar, except that it contains additional code`to support Oracle Dynamic Monitoring Service.
classes12dms_g.jar (2,078,718 bytes) - same as classes12dms.jar except that classes were compiled with "javac -g" and contain some tracing information.
ojdbc14.jar (1,569,316 bytes) - classes for use with JDK 1.4 and 1.5
ojdbc14_g.jar (1,965,422 bytes) - same as ojdbc14.jar, except that classes were compiled with "javac -g" and contain some tracing information.
ojdbc14dms.jar (1,576,882 bytes) - same as ojdbc14.jar, except that it contains additional code`to support Oracle Dynamic Monitoring Service.
ojdbc14dms_g.jar (1,973,634 bytes) - same as ojdbc14dms.jar, except that classes were compiled with "javac -g" and contain some tracing information.
demo.tar (604,160 bytes) - contains sample JDBC programs.
I'm using JDK 1.7 and windows XP 32 bit
 
Ulf Dittmer
Rancher
Posts: 42969
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Which one do you think would be the best choice for your situation?
 
arjun gaur
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i guess ojdbc14.jar,it supports jdk1.4 so must support 1.7 as well ?
 
Ulf Dittmer
Rancher
Posts: 42969
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Good choice :-)
 
arjun gaur
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i downloaded the driver so what do i need to do..
1) include the jar file in my classpath.but i have already includede the javaFX jar file
.;C:\Program Files\Java7\jdk1.7.0_51\jre\lib\jfxrt.jar
So should i remove that one or simply add the ojdbc14.rar after it..
And what changes to be made in Connection URL and driver class name.
Thanks
 
Ulf Dittmer
Rancher
Posts: 42969
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What do you mean, "but"? What does the JavaFX jar file have to do with the JDBC driver? For a JavaFX app that uses JDBC you need both, yes?

As to the connection details , a search phrase such as "oracle jdbc connection url" or "oracle jdbc driver class name" suggests itself. Much faster than waiting for a reply here.
 
arjun gaur
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
right now i'm not using javaFX app .so ok i'll remove that jar file and add ojdbc14.jar.
what about driver name and Connection url.you said i'v to make changes in these cases.So what should i write ?
I guess the following lines need to be modified:
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection con=DriverManager.getConnection("jdbcdbc:Hospital");
So tell me what should i change
Thanks..
 
Ulf Dittmer
Rancher
Posts: 42969
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I had edited my previous post with a suggestion for you how to find that out.
 
arjun gaur
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i searched for it and i got the following results

Connection conn = DriverManager.getConnection
("jdbc : oracle : oci8 : scott/tiger@myhost);

Connection conn = DriverManager.getConnection
("jdbc : oracle : thin:scott/tiger@myhost:1521 : orcl);

My username :hr password:hr
but i don't know about "oci8" @myhost : 1521 : orcl etc in the above lines
 
arjun gaur
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
and for registering
Class.forName ("oracle . jdbc . OracleDriver");
 
arjun gaur
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hey!
I downloaded ojdbc14.jar,included it in the classpath
made the following changes:

Class.forName ("oracle.jdbc.OracleDriver");
Connection con = DriverManager.getConnection ("jdbc : oracle : thin : hr/hr@myhost : 1521 : orcl");

username:hr
password:hr
I'v created the table in Oracle express Edition 10g ,logged in.
i'm getting java.sql.SQLException:the network adapter could not establish connection.
Please help.
I'm not sure about that line in url "@myhost : 1521 : orcl" , i just copied it from oracle site.



I even tried :
Connection con = DriverManager.getConnection ("jdbc : oracle : thin : hr/hr@localhost : 1521 : orcl");
Connection con = DriverManager.getConnection ("jdbc : oracle : thin : hr/hr@localhost : 1521 : XE");
But it's saying "Listener does not currently know of SID given in connect descriptor"
Please help
Thanks
 
Ulf Dittmer
Rancher
Posts: 42969
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Making random changes when you don't understand what you're changing is not a good way to solve a problem. I suggest you find the driver's documentation on Oracle's site and read the details on how to make a connection. On Google, you can restrict search results to a particular site by adding "site:oracle.com" to your search phrase.
 
arjun gaur
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I edited my post please read it again..
i made the changes to SID ,i found out somewhere that by default SID for oracle express edition is XE,i changed to it still getting the error
Thanks
 
Ulf Dittmer
Rancher
Posts: 42969
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Not sure what you have read since my previous post (given the short time span that passed, probably not much). Start with http://www.orafaq.com/wiki/JDBC. Make sure service name or SID (whichever you use) are correct.
 
arjun gaur
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Looked up everywhere.but couldn't figure out what to do
still getting that TNs listener error.
looked into my listener.ora there sid_name=PLSExtProc
so i even tried this
Connection con=DriverManager.getConnection("jdbc : oracle : thin : @localhost : 1521 : PLSExtProc", "hr", "hr");
Now getting the error :"listenere failed to start a dedicated server process"
 
chris webster
Bartender
Posts: 2407
33
Linux Oracle Postgres Database Python Scala
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Looking at your posts, it seems like you have very little idea of how JDBC or SQL works, so maybe you should take an hour or two to work through a few of the simple examples on the JDBC Tutorial? These should help to give you a better foundation for understanding what you're actually trying to do.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic