ORACLE CONNECTION FROM JAVA

ORACLE CONNECTION FROM JAVA

Post by SVupalan » Fri, 06 Mar 1998 04:00:00



Hi All,

We have Oracle7.2 running on SUN. I need to connect to Oracle. Basically I dont
know where to start It's kind of emergency situation. If anyone help me in
connecting to the Database it's really helpful. If you send me some steps of
process. I am a JAVA programmer I have no idea about connectiong to the
Database. If you send me the scripts and steps to follow its a big help. I will
be waiting for your reply.

Sreedhar Vupalanchi
please reply to:


 
 
 

ORACLE CONNECTION FROM JAVA

Post by Mikhail Galbmillio » Tue, 10 Mar 1998 04:00:00



> Hi All,

> We have Oracle7.2 running on SUN. I need to connect to Oracle. Basically I dont
> know where to start It's kind of emergency situation. If anyone help me in
> connecting to the Database it's really helpful. If you send me some steps of
> process. I am a JAVA programmer I have no idea about connectiong to the
> Database. If you send me the scripts and steps to follow its a big help. I will
> be waiting for your reply.

> Sreedhar Vupalanchi
> please reply to:



  *******************************************************************
you can try this:

import java.sql.*;
import  whatever you need .............................................

public class JdbcData {
  static Connection databaseConnection;
  String driverName;
  String sourceURL;
  String [] data;

  public JdbcData() throws SQLException,ClassNotFoundException{
    Drivermanager.registerDriver(new oracle.jdbc.driver.OracleDriver.Driver());

    databaseConnection=DriverManager.getConnection (sourceURL,"username",
"password");
  }

  public void Disconnect() throws SQLException{
    databaseConnection.close();
  }

  /* fetches Bureau names from database */
  public String[] listNames() throws SQLException {
    Statement getName;
    ResultSet theName;

    String query = "select ename from employee ";
    getName=databaseConnection.createStatement();
    theName=getBureau.executeQuery(query);
    while(theBureau.next()){
      add to data[](theName.getString(1));
    }
    getBureau.close();

    return data;
  }

public static void main(String[] args){
  JdbcData jdbc_try;
    String empNames[];

    try {
      jdbc_try= new JdbcData();
      empNames=jdbc_try.listNames()();
      jdbc_try.Disconnect();
   }
    catch(SQLException sqle){
       System.out.println("SQL Exception: " + sqle);
    }
    catch (ClassNotFoundException cnfe){
       System.out.println("Cnf: " + cnfe);
       cnfe.printStackTrace();
    }
  }

Quote:}

Check Oracle documentation for compleate info about Oracle 7 JDBC Drivers.
Also, you will need JDBC support for Netscape if you are going to run applets.
Hope this will help.
Sincerely ,
Mikhail Galbmillion

 
 
 

1. Oracle connection with java

this is my tnsnames.ora

PROD.WORLD =
  (DESCRIPTION =
    (SOURCE_ROUTE = YES)
    (ADDRESS_LIST =
      (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.254.250)(PORT = 1521))
      (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.0.6)(PORT = 1521))
    )
    (CONNECT_DATA = (SID = PROD))
  )

What should my jdbc thin connection string be ?

2. NJ-New Jersey-56634--SUN-Solaris-TCP/IP-UNIX-ORACLE-Lead Integration Consultant

3. Procedure FieldNames & Delemiters

4. sql statement differences

5. Java connection pooling vs oracle connection pooling

6. XML Encoding

7. ---JAVA-----JAVA-----JAVA-----JAVA-----JAVA-----JAVA-----JAVA-----JAVA---

8. CA-SAN FRANCISCO-359298--Java-Java-Java-ORACLE-JAVA SERVER ENGINEER

9. CA-SUNNYVALE-258310--Java-ERP-XML-ORACLE-ORACLE APPLICATION ARCHITECT -- XML JAVA EAI TIBCO

10. GA-Atlanta Area-269516--Java-HTML-ORACLE-Windows-Java programmers, HTML, Oracle, Windows