Win a copy of JDBC Workbook this week in the JDBC and Relational Databases forum
or A Day in Code in the A Day in Code forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Jeanne Boyarsky
  • Junilu Lacar
  • Henry Wong
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Frits Walraven
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • salvin francis
  • fred rosenberger

Connecting to remote database

 
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
Please help me with the getconnection method I am stuck in the parameters URL is the mail part.

Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); -- I have used this database driver.

c=DriverManager.getConnection("url","username","password")

the TNS data with which I am connecting to tha database is

FCFINUPG=
(DESCRIPTION=
(ADDRESS=(PROTOCOL=tcp)(HOST=fcapp3.femcom.net)(PORT=1529))
(CONNECT_DATA=
(SERVICE_NAME=FCFINUPG)
(INSTANCE_NAME=FCFINUPG)
)
)

 
Ranch Hand
Posts: 1087
Oracle Spring Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You are using ODBC connection, Did you define an ODBC datasource on your machine ?

Shailesh
 
saurabh dudeja
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Shailesh Chandra wrote:You are using ODBC connection, Did you define an ODBC datasource on your machine ?

Shailesh



earlier I used Class.forName("oracle.odbc.driver.OracleDriver"); but it was not working.

the database is not in my local machine. so what should I do suggest me.
 
Shailesh Chandra
Ranch Hand
Posts: 1087
Oracle Spring Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think you did you get what I wanted to ask. I was asking that did you define a DSN or your machine.

If you want to create a type 4 conenction, then you should use class orale.jdbc.driver.OracleDirver


Shailesh
 
saurabh dudeja
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hey shailesh

earlier I used Class.forName("oracle.jdbc.driver.OracleDriver"); i then debug it it was not working fine.

then I use Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); I don't know what to do next please help me.
 
saurabh dudeja
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am using below parameter in the forName() method

Class.forName("oracle.jdbc.driver.OracleDriver")
while running I am getting this error

java.lang.ClassNotFoundException: oracle.jdbc.driver.OracleDriver

any suggestions
 
Bartender
Posts: 10336
Hibernate Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
sun.jdbc.odbc.JdbcOdbcDriver is the JDBC-ODBC bridge. It would be an unusualy thing to do to use this to connect to Oracle. Have a read of this to see why.

Oracle supplies a proper "type 4" driver (if you have not heard that term have a read of ththis) which would be the normal way to connect. If you don't already have it you can get it here; this link also included the documentation and example of how to use it.
 
saurabh dudeja
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
so which driver should I use suggest me
 
Paul Sturrock
Bartender
Posts: 10336
Hibernate Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

saurabh dudeja wrote:so which driver should I use suggest me



Didn't I just do that?
 
saurabh dudeja
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have the driver file ojdbc14.jar in my Lib folder where oracle is installed. now what to do suggest me.
 
Paul Sturrock
Bartender
Posts: 10336
Hibernate Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I suggest you move it into your classpath.
 
saurabh dudeja
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hey I have included the file ojdbc14.jar in the class path. but still it is showing the error.
 
Paul Sturrock
Bartender
Posts: 10336
Hibernate Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What error?
 
saurabh dudeja
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
while runnning the program its giving error as

java.lang.ClassNotFoundException: oracle.jdbc.driver.OracleDriver
at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:276)
at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:169)
at db_connect_test.<init>(db_connect_test.java:17)
at db_connect_test.main(db_connect_test.java:56)
 
Paul Sturrock
Bartender
Posts: 10336
Hibernate Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
So its not in your classpath. Where did you put ojdbc14.jar?
 
saurabh dudeja
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I right click on my computer(icon) properties--> advance--> environment variables then there system variables path. In that i have put the path.
 
Paul Sturrock
Bartender
Posts: 10336
Hibernate Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

saurabh dudeja wrote:I right click on my computer(icon) properties--> advance--> environment variables then there system variables path. In that i have put the path.



The path is not the classpath. Have a read of this.
 
saurabh dudeja
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hey I got the result it worked thanks a ton
 
You showed up just in time for the waffles! And this tiny ad:
Devious Experiments for a Truly Passive Greenhouse!
https://www.kickstarter.com/projects/paulwheaton/greenhouse-1
    Bookmark Topic Watch Topic
  • New Topic