General discussion

Locked

Connect Oracle using JAVA

By jramalin ·
Hi there,

I am trying to connect to the Oracle Database using JAVA. What are the utilities required and what will be the statements to establish database connectivity and retrive records from Oracle?

Please guide me!

Regards,

Jothiram@hotmail.com

This conversation is currently closed to new comments.

3 total posts (Page 1 of 1)  
| Thread display: Collapse - | Expand +

All Comments

Collapse -

Connect Oracle using JAVA

by rajiv.srivastava In reply to Connect Oracle using JAVA

Hi,
You need to import the javax.sql package in your program and then use the different methods of this class. I am attaching a small code for your reference.
This program assumes that u have a ODBC connectivity to Oracle, it reads the data from table and prints it on console
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection con = DriverManager.getConnection("jdbc:odbc:"+yourDSN"+,"scott","tiger");
Statement st = con.createStatement();
ResultSet rs = st.executeQuery("select * from anyTableyouwant");
int c =rs.getMetaData().getColumnCount();
while (rs.next())
{
for (int i=1;i<=c ;i++ )
{
System.out.print(rs.getString(i)+"\t");
}
System.out.println();
}

Collapse -

Connect Oracle using JAVA

by jramalin In reply to Connect Oracle using JAVA

Thank u very much...

Collapse -

Connect Oracle using JAVA

by jramalin In reply to Connect Oracle using JAVA

This question was closed by the author

Back to Web Development Forum
3 total posts (Page 1 of 1)  

Related Discussions

Related Forums