Win a copy of Mastering Non-Functional Requirements this week in the Design forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

oracle and jdbc-odbc bridge  RSS feed

Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am facing a problem in connecting this simple program
to the oracle8 database.
I am trying
to connect to the oracle database (which is residing
on my local machine as of now) through a JDBC-ODBC
bridge, and then execute the "emp" table of the "scott" user
---> what i am still not familiar is how to pass the connection string in
the ODBC data source administrator dialog box?
--> what kind of entry i should make
in TNSnames.ora file, to connect to the local database where the "emp"
table is situated?
--> how do i know the host and Port no for the database on which the
"emp" table resides?

import java.sql.*;
public class CreateCoffees1 {
public static void main(String args[]) throws IOException {
String url = "jdbcdbc:testing";
Connection con;
Statement stmt;

try {
/*we are creating a connection to the database using the JDBC-Bridge Driver*/
catch(java.lang.ClassNotFoundException e) {
System.err.print("ClassNotFoundException: ");
try {
con = DriverManager.getConnection(url,"scott","tiger");
stmt = con.createStatement();
ResultSet srs = stmt.executeQuery("SELECT * FROM emp");
while ( {
String name = srs.getString("ENAME");
String job = srs.getString("JOB");
System.out.println(name + " " + job);

} catch(SQLException ex) {
System.err.println("SQLException hai bhai: " + ex.getMessage());

thanks in advance.
NageswaraRao Karra
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
if it is for localhost there is no need to make in entries in tnsnames.ora file.
simply creating dsn is enough.
goto control panel-click odbc32..icon-in the dialog press add-
select the oracledriver-enter will find it very easy.
i hope this is what you wanted
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!