File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes JDBC and Relational Databases and the fly likes oracle and jdbc-odbc bridge Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC and Relational Databases
Bookmark "oracle and jdbc-odbc bridge" Watch "oracle and jdbc-odbc bridge" New topic

oracle and jdbc-odbc bridge

Ranch Hand

Joined: Nov 22, 2008
Posts: 18944
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

Joined: Nov 12, 2000
Posts: 34
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
I agree. Here's the link:
subject: oracle and jdbc-odbc bridge
It's not a secret anymore!