aspose file tools*
The moose likes JDBC and the fly likes how can I know my TNS Names_Entry? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC
Bookmark "how can I know my TNS Names_Entry?" Watch "how can I know my TNS Names_Entry?" New topic
Author

how can I know my TNS Names_Entry?

ankur rathi
Ranch Hand

Joined: Oct 11, 2004
Posts: 3830
Hi,
I am trying to connect java with oracle with oci deriver. I have both oracle and java on one machine.


This line works perfectly (doesn't give ClassNotFoundException), taken classes111.zip file into classpath.



What should I write at the place of TNS Names_Entry. Actually what exactly is this TNS Names_Entry. How can I know the value of this in my computer.

Please help me.

Thanks a lot.
[ November 13, 2005: Message edited by: rathi ji ]
Arun Prasath
Ranch Hand

Joined: Sep 17, 2003
Posts: 192
First, you should have oracle client installed in your machine when you use oracle oci driver.

Then look for the file tnsnames.ora inside "admin" folder of oracle client installation. This file holds the details of the list of services configured by your client.

pick the required service name and use in your java program.


SCJP 1.4, SCDJWS , SCJA<br />I can do ALL things through CHRIST who strengthens me.
ankur rathi
Ranch Hand

Joined: Oct 11, 2004
Posts: 3830
I guess, I have both server and client installed. Because I am writing query from SQL plus prompt (I guess, without client, we can't make query) and server is executing the query.

Unfortunately, I can't look this file now.

Is there a direct entry like this in tnsnames.ora file:

TNS Names_Entry = SHREE

Please reply.
Thanks.
Sunil Dumpala
Greenhorn

Joined: Jul 28, 2005
Posts: 29
Rathi,

A usual tnsname entry looks like the following

SUNILDB =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP) (HOST = SUNIL01) (PORT = 1521))
)
(CONNECT_DATA =
(SID = SUNILDB)
(SERVER=DEDICATED)
)
)

-Sunil
Paul Sturrock
Bartender

Joined: Apr 14, 2004
Posts: 10336

And to double check the value you think is the tns name, try "tnsping [tnsname]" from the command line.


JavaRanch FAQ HowToAskQuestionsOnJavaRanch
ankur rathi
Ranch Hand

Joined: Oct 11, 2004
Posts: 3830
Originally posted by Sunil Dumpala:
Rathi,

A usual tnsname entry looks like the following

SUNILDB =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP) (HOST = SUNIL01) (PORT = 1521))
)
(CONNECT_DATA =
(SID = SUNILDB)
(SERVER=DEDICATED)
)
)

-Sunil



Thank you very much Sunil and Paul.
Could you please tell me what is TNS Names_Entry here in this file.
David O'Meara
Rancher

Joined: Mar 06, 2001
Posts: 13459

SUNILDB = ...

SUNILDB is the TNS name.
ankur rathi
Ranch Hand

Joined: Oct 11, 2004
Posts: 3830
Originally posted by David O'Meara:
SUNILDB = ...

SUNILDB is the TNS name.


Thanks David,
I will try this.

ankur rathi
Ranch Hand

Joined: Oct 11, 2004
Posts: 3830
I tried this code.



It was giving this error:



Please tell me, what can be wrong here?
Thanks.
[ November 22, 2005: Message edited by: rathi ji ]
Sri Ram
Ranch Hand

Joined: Oct 03, 2005
Posts: 118
I dont know if this will anyway solve ur issue, But it did mine some time back.
First, make sure that the jdbc-oci shared object (libocijdbc8 or liboci80Xjdbc.so etc.) and ${ORACLE_HOME}/lib are in your path. Then, try the Test sample program available in the JDBC samples directory. Sometimes, even after the shared object is loaded successfully, you may get errors such as make_c_state symbol not found. This may happen if your CLASSPATH has classes.zip from JRE 1.1.7 or JDK 1.1.6 and your running java binaries from jdk 1.1.3 or so. Make sure everything (LD_LIBRARY_PATH, CLASSPATH, java binaries) is in sync.
Sri Ram
Ranch Hand

Joined: Oct 03, 2005
Posts: 118
Sorry forgot to post. I actually got this from Here.
ankur rathi
Ranch Hand

Joined: Oct 11, 2004
Posts: 3830
Originally posted by Sri Ram:
I dont know if this will anyway solve ur issue, But it did mine some time back.
First, make sure that the jdbc-oci shared object (libocijdbc8 or liboci80Xjdbc.so etc.) and ${ORACLE_HOME}/lib are in your path. Then, try the Test sample program available in the JDBC samples directory. Sometimes, even after the shared object is loaded successfully, you may get errors such as make_c_state symbol not found. This may happen if your CLASSPATH has classes.zip from JRE 1.1.7 or JDK 1.1.6 and your running java binaries from jdk 1.1.3 or so. Make sure everything (LD_LIBRARY_PATH, CLASSPATH, java binaries) is in sync.


I am sorry but I didn't get it.

I have classes111.zip into classpath. Using JDK 1.4 and Oracle 8i. Are they not compatible with each other.

Please help.

Thanks.

Jesper de Jong
Java Cowboy
Saloon Keeper

Joined: Aug 16, 2005
Posts: 14350
    
  22

You have to make sure that the relevant OCI DLL's (if you're using Windows) are in the PATH (note, that's not the same as classpath).

The error you are getting:

Unsatisfied link error make_c_safe at oracle.jdbc.oci8.OCIDBAccess.make_c_safe

sounds like you do have the DLL's in your path, but you have a wrong (too old or too new) version somewhere.

Why do you want to use the OCI driver anyway? Using the thin driver is easier, if you use the thin driver you don't need the Oracle client software at all (and you wouldn't have problems like the error message above).

edit: Aha, I see you have another post which is exactly the same, except you're asking about the thin driver... :roll:
[ November 22, 2005: Message edited by: Jesper de Jong ]

Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 8 API documentation
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: how can I know my TNS Names_Entry?