English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

Hello,

I have written a java program in JDK 1.4 ( Which I have compiled in J++).
I am dont know how to connect oracle ( 9i / 10g) as Backend to my java program.

Please send the code / instructions to connect my backend.

my program includes oracle tables..

Please help me..

thank you
Jayanth

2006-11-14 16:29:47 · 3 answers · asked by JaYaNtH 3 in Computers & Internet Programming & Design

How to display a oracle table as output from a Java program.. Pls post replies..

2006-11-20 16:36:23 · update #1

3 answers

You have to specify the dsn name, using the following guidelines.

Goto Control Panel
Start > Settings > Control Panel
Double Click the Administrative Tools
Double Click the Data Sources (ODBC)
a window will appear with title as
ODBC Data Source Administrator
Click on the System DSN Tab at the top
then Click on the Add Button
Choose Driver from the list of drivers
Here in your case it is
Microsoft Access Driver (*.mdb)
Then Click Finish

A window appears asking Data Source Name (Type here the data source name)
specify the server, user name and password
then press ok
Your dsn is ready now.

You have to specify it on the programming code.
Here's the code for connectivity.
import java.sql.*;
// code snippet
try{

Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection con=DriverManager.getConnection("jdbc:odbc:","","");
Statement stmt=con.createStatement();
// now to execute queries
ResultSet rs=stmt.executeQuery("");
//you can get values by using rs.getString()
int i=stmt.executeUpdate("");
}
catch(Exception exception){
System.out.println("Error"+exception.getMessage());
}

for further clarifications you can contact me

my email:ananthasivanvk@gmail.com
my mobile number : +919995403653

good luck.

2006-11-15 16:24:45 · answer #1 · answered by Anand 3 · 2 0

Use JDBC. Simple few line code is avail in most the java books with complete set of instructions.

Create a DSN in odbc32 in ur control panel

Then write JDBC

2006-11-14 21:02:31 · answer #2 · answered by mtda 1 · 0 0

public void CreateConnection(){


try {
Class.forName
("oracle.jdbc.driver.OracleDriver");
} catch (Exception e) {
System.out.println("Failed to load JDBC/ODBC driver.");
return;
}
// get a connection
try {
Connection con = DriverManager.getConnection(
"jdbc:oracle:thin:@servername:1521:orcl",

"test",
"test");
} catch (Exception e) {
System.err.println("problems connecting to server" );
}
}




Hope u make sense out of this ... Some idioting fonting of yahoo ... Some things may get cut out.. Try it

2006-11-16 22:15:47 · answer #3 · answered by meetyou1 1 · 0 0

fedest.com, questions and answers