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  
Old 09-24-2007, 10:43 PM
amansundar amansundar is offline
D-Web Analyst
 
Join Date: May 2007
Posts: 319
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
  #2  
Old 09-24-2007, 10: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  
Old 09-24-2007, 10:48 PM
S.Vinothkumar S.Vinothkumar is offline
D-Web Genius
 
Join Date: May 2007
Posts: 905
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  
Old 09-24-2007, 10:57 PM
krishnakumar krishnakumar is offline
D-Web Analyst
 
Join Date: May 2007
Posts: 200
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  
Old 09-24-2007, 10:59 PM
leoraja8 leoraja8 is offline
D-Web Sr.Programmer
 
Join Date: May 2007
Posts: 190
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
  #6  
Old 03-24-2009, 06:19 AM
leveup2 leveup2 is offline
D-Web Trainee
 
Join Date: Mar 2009
Posts: 8
leveup2 is on a distinguished road
Default Re: JAVA Oracle connectivity with Jdbc-odbc bridge

is really useful for me, I am glad to read it here.
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 Off
Pingbacks are Off
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
java oracle database connectivity aaratipatil Java Programming 0 03-27-2009 09:43 PM
Difference between JDBC and ODBC? vijayanand Java Programming 0 09-20-2007 07:05 AM
Can the JDBC-ODBC Bridge be used with applets? bluesky Mobile Software Development 2 09-04-2007 07:04 AM
Parameters and Variables in Oracle through ODBC (VS2005) $enthil VB.NET Programming 2 08-17-2007 05:56 AM
Open Database Connectivity (ODBC) Murali Database Support 0 07-16-2007 03:02 AM


All times are GMT -7. The time now is 07:14 PM.


Copyright ©2004 - 2007, DiscussWeb. All Rights Reserved.
Our Partners
One Way Moving Companies | Stamford Dentist | Euro Millions Lottery | Home Loans| Furniture

SEO by vBSEO 3.0.0