Forum     

Go Back   Digit Technology Discussion Forum > Software > Programming
Register FAQ Calendar Mark Forums Read

Programming The destination for developers - C, C++, Java, Python and the lot


Closed Thread
 
LinkBack Thread Tools Display Modes
Old 29-03-2008, 05:46 PM   #1 (permalink)
Right Off the Assembly Line
 
Join Date: Nov 2007
Posts: 28
Default Cannot connect java with oracle


Hiplease help as i have problem connecting java with oracle the connectioncode which i m implementing is working in my college but not a my place

Class.forName("oracle.jdbc.driver.OracleDriver");

Connection con = DriverManager.getConnection("jdbc:Oracle:thin:@//ip address of college:1521/orcl9i", "name", "password");


as i m entering the loop back address i.e 127.0.0.1 which is not accepting

Last edited by nitinm; 29-03-2008 at 05:56 PM. Reason: no spacing
nitinm is offline  
Advertisements. Register and be a member of the community to get rid of them.
Advertisement

Old 29-03-2008, 06:09 PM   #2 (permalink)
Wahahaha~!
 
Faun's Avatar
 
Join Date: Dec 2006
Location: Pune/there
Posts: 7,675
Default Re: Cannot connect java with oracle

yeah the loopback is for when the server is runnin on same computer
Code:
import java.sql.*;
class dbAccess {
  public static void main (String args []) throws SQLException
  {
    Connection con=null;
        try {
              Class.forName ("oracle.jdbc.driver.OracleDriver");
        System.out.println("Driver loaded successfully");
        con = DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:dsn","scott","tiger");
                                              // @machineName:port:SID,   userid,  password
        System.out.println("connection established");
        Statement db_statement = con.createStatement();
        // Create a simple table, which stores an employee ID and name
        db_statement.executeUpdate("create table employee( empid varchar2(5), firstname varchar2(10), salary number(7))");
    
        // Insert an employee, so the table contains data
        db_statement.executeUpdate("insert into employee values('1234','JohnDoe',1234567)");


        // Execute query
        ResultSet result = db_statement.executeQuery("select * from employee");

        // While more rows exist, print them
        while (result.next() )
        {
        // Use the getInt method to obtain emp. id
        System.out.println ("ID : " + result.getString("empid"));

        // Use the getString method to obtain emp. name
        System.out.println ("Name : " + result.getString("firstname"));
        System.out.println ("Salary : " + result.getInt("salary"));
        //System.out.println ();
        }
        
        // Commit changes
        //con.commit();

            
        } catch (ClassNotFoundException e) {
              e.printStackTrace();

        }
http://www.exampledepot.com/egs/java...ectOracle.html
__________________
Blog | Flickr | Battlelog
Spoiler:
Asus Z68 V-Pro|i5 2500k|TRUE Black|Ripjaws X|U2311H|N560GTX|D7000|XONAR STX|RE272|RE0|CC51|XE200PRO Walnut| TD II V2| Ultraphile|N5800

Mono
Faun is online now  
Closed Thread

Bookmarks

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

BB 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
Can I connect 2 internet connections Connect at a time? gaju6696 Internet & WWW 6 06-02-2009 08:26 PM
Oracle Unveils Oracle(r) Virtual Machine Garbage Technology News 2 15-11-2007 06:58 PM
Oracle Versions and Supported OSs etc., about Oracle sravan_mdo Software Q&A 1 27-08-2006 05:59 PM
OPERA MINI WORKING & ALL JAVA SOFTWARE CONNECT TO INTERNET vamsee Mobiles and Tablets 3 18-01-2006 07:35 PM

 
Latest Threads
- by Charan
- by Sarath
- by clmlbx

Advertisement




All times are GMT +5.5. The time now is 12:56 AM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2012, vBulletin Solutions, Inc.

Search Engine Optimization by vBSEO 3.3.2