IT Community - Software Programming, Web Development and Technical Support

JAVA Oracle connectivity with Jdbc-odbc bridge

This is a discussion on JAVA Oracle connectivity with Jdbc-odbc bridge within the Java Programming forums, part of the Software Development category; Hello, I am newbie in JDBC. Can anybody provide me the code for connecting to oracle through Jdbc-Odbc bridge. ...


Go Back   IT Community - Software Programming, Web Development and Technical Support > Software Development > Java Programming

Register FAQ Members List Calendar Mark Forums Read
  #1 (permalink)  
Old 09-24-2007, 11:43 PM
amansundar amansundar is offline
D-Web Analyst
 
Join Date: May 2007
Posts: 325
amansundar is on a distinguished road
Default JAVA Oracle connectivity with Jdbc-odbc bridge

Hello,

I am newbie in JDBC. Can anybody provide me the code for connecting to oracle through Jdbc-Odbc bridge. I have already created a system dsn (Microsoft ODBC for Oracle) named "orajava".
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 09-24-2007, 11:45 PM
mobilegeek mobilegeek is offline
D-Web Analyst
 
Join Date: Jun 2007
Posts: 205
mobilegeek is on a distinguished road
Default Re: JAVA Oracle connectivity with Jdbc-odbc bridge

hi,

Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection con=DriverManager.getConnection("jdbcdbcrajava ","scott","tiger");

After this you can create statement or prepared Statement object depending on your application.
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 09-24-2007, 11:48 PM
S.Vinothkumar S.Vinothkumar is offline
D-Web Genius
 
Join Date: May 2007
Posts: 1,061
S.Vinothkumar is on a distinguished road
Default Re: JAVA Oracle connectivity with Jdbc-odbc bridge

1step is: getdriver
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");


2 step is register the URL
Connection con=DriverManager.getConnection("jdbcdbcrajava ","scott","tiger");


3step is : create the statement

Statemnt st=con.createStatement();

4 step is: Execute the Query and get the results from resultset


4 step is: close the all connections
__________________
S.VinothkumaR
Behind me is infinite power,
Before me is Endless Possibility,
Around me is Boundless Opportunity,
Why should I fear!
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 09-24-2007, 11:57 PM
krishnakumar krishnakumar is offline
D-Web Analyst
 
Join Date: May 2007
Posts: 206
krishnakumar is on a distinguished road
Default Re: JAVA Oracle connectivity with Jdbc-odbc bridge

hi aman,
this link provides you sll the necessary details for making connection to oracle through java....

Java Database Connectivity Guide
__________________
Krishnakumar.S
Beware of Everything -that is un true; stick to the Truth shall succeed slowly but steadily
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #5 (permalink)  
Old 09-24-2007, 11:59 PM
leoraja8 leoraja8 is offline
D-Web Sr.Programmer
 
Join Date: May 2007
Posts: 194
leoraja8 is on a distinguished road
Default Re: JAVA Oracle connectivity with Jdbc-odbc bridge

The Following code will help u..............

PHP Code:
import java.sql.*;
import javax.naming.*;
import javax.sql.DataSource;

public class 
Main 
{
    
    
/** Creates a new instance of Main */
    
public Main()
    {
        
    }
    
    
/**
     * @param args the command line arguments
     */
    
public static void main(String[] args
    {
         
        
Connection con null;
        
Statement st null;
        
PreparedStatement pt null;
        
CallableStatement ct null;
        try
        {

            Class.
forName("sun.jdbc.odbc.JdbcOdbcDriver");
            
con DriverManager.getConnection("jdbc:odbc:orajava""scott","tiger");
            
            
//Statement
            
st con.createStatement();
            
st.executeUpdate("insert into sample values(1,'abcd')");
            
            
//CallableStatement(pname->procedure name ,  parameter)
//            ct = con.prepareCall("{call pname(1)}");
//            ct.execute();
//            
            //PreparedStatement
            
pt con.prepareStatement("select * from sample");
            
ResultSet rs pt.executeQuery();
            
            
System.out.println("Number\tName");
            
System.out.println("------------");
            
            while(
rs.next())
            {
                
System.out.print(rs.getInt("num"));
                
System.out.print("\t"+rs.getString("nam")+"\n");
            }
            
System.out.println("------------");
        }
        catch(
SQLException e)
        {
            
System.out.println(e.getMessage());
        }
        catch(
Exception  e)
        {
            
System.out.println(e.getMessage());
        }
    }    

Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Difference between JDBC and ODBC? vijayanand Java Programming 0 09-20-2007 08:05 AM
Which is the fastest type of JDBC driver in Java? leoraja8 Java Programming 2 09-05-2007 08:31 AM
Can the JDBC-ODBC Bridge be used with applets? bluesky Mobile Software Development 2 09-04-2007 08:04 AM
Parameters and Variables in Oracle through ODBC (VS2005) $enthil VB.NET Programming 2 08-17-2007 06:56 AM
Open Database Connectivity (ODBC) Murali Database Support 0 07-16-2007 04:02 AM


All times are GMT -7. The time now is 11:31 PM.


Copyright ©2004 - 2007, DiscussWeb. All Rights Reserved.

SEO by vBSEO 3.0.0