This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes JDBC 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


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "oracle and jdbc-odbc bridge" Watch "oracle and jdbc-odbc bridge" New topic
Author

oracle and jdbc-odbc bridge

Anonymous
Ranch Hand

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

import java.io.*;
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*/
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
}
catch(java.lang.ClassNotFoundException e) {
System.err.print("ClassNotFoundException: ");
System.err.println(e.getMessage());
}
try {
con = DriverManager.getConnection(url,"scott","tiger");
stmt = con.createStatement();
ResultSet srs = stmt.executeQuery("SELECT * FROM emp");
while (srs.next()) {
String name = srs.getString("ENAME");
String job = srs.getString("JOB");
System.out.println(name + " " + job);
}

stmt.close();
con.close();
} catch(SQLException ex) {
System.err.println("SQLException hai bhai: " + ex.getMessage());
}
}
}
</code>

thanks in advance.
NageswaraRao Karra
Ranch Hand

Joined: Nov 12, 2000
Posts: 34
hello!friend
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 dsn...etc..you will find it very easy.
i hope this is what you wanted
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: oracle and jdbc-odbc bridge
 
Similar Threads
Hi,I have a problem in database connection
Invalid operation for read only resultset: updateFloat
What's wrong with this code?
help wanted
oracle connection with jdbc