This week's book giveaway is in the Agile and Other Processes forum.
We're giving away four copies of The Little Book of Impediments (e-book only) and have Tom Perry on-line!
See this thread for details.
Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to connect to Oracle db using TNS

 
Steve Campbell
Ranch Hand
Posts: 41
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm able to use the thin client to connect to the db, but can't figure out the syntax for connecting using TNS. Our db group here has put the TNS files onto a common server, and instucted us to us the TNS name only. It works ok using Toad, and when I write C# programs I don't have a problem.
Does anyone know how to connect his way?
Thanks,
Steve
 
Jamie Robertson
Ranch Hand
Posts: 1879
MySQL Database Suse
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
have at look at the Oracle9i JDBC Developer's Guide and Reference - Opening a Connection for the JDBC OCI Driver. Specifically it says:
"For the JDBC OCI driver, you can specify the database by a TNSNAMES entry. You can find the available TNSNAMES entries listed in the file tnsnames.ora on the client computer from which you are connecting. On Windows NT, this file is located in the [ORACLE_HOME]\NETWORK\ADMIN directory. On UNIX systems, you can find it in the /var/opt/oracle directory.
For example, if you want to connect to the database on host myhost as user scott with password tiger that has a TNSNAMES entry of MyHostString, enter:
Connection conn = DriverManager.getConnection
("jdbcracleci:@MyHostString", "scott", "tiger");

Note that both the ":" and "@" characters are necessary."
Jamie
[ January 06, 2004: Message edited by: Jamie Robertson ]
 
Loren Rosen
Ranch Hand
Posts: 156
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm pretty sure (with 8i at least) that you can't use a name server with the thin driver. That driver was designed for use with Applets, where a name server wouldn't make sense.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic