Exforsys
+ Reply to Thread
Results 1 to 6 of 6

oracle database connectivity

This is a discussion on oracle database connectivity within the Java forums, part of the Programming Talk category; Hi all can any one tell me , how to connect the database in java? Is there any need to ...

  1. #1
    gayatri is offline Junior Member Array
    Join Date
    Feb 2005
    Answers
    1

    oracle database connectivity

    Hi all

    can any one tell me ,
    how to connect the database in java?
    Is there any need to set any path in the env variable for execution ?

    thanx in advance,
    g3.



  2. #2
    kalareddy Guest

    Re:oracle database connectivity

    Oracle Corporation has released a free 100% JAVA driver. It is available at their Web site. According to the security rule, the Oracle server must be on the same machine as the Web server, since the communication with the Applet is done through Sockets. This is not always possible, so you will need something called a Connection Manager (from Oracle) or DBAnywhere from Symantec (demo version available for testing) to act as a bridge between the client, the Web server and the Database server.

    Script sample :

    import java.sql.*;

    public class connectToOracle extends java.applet.Applet {
    Driver driver;
    Connection conn = null;
    static String driverUsed =
    \"oracle.jdbc.driver.OracleDriver\";
    static String serverAddress =
    \"jdbcracle:thin:scott/tiger@www.myCompany.com:1243:myInstance\";
    // jdbcracle:thin is the driver used
    // scott/tiger is user/password
    // www.myServer.com is the same machine from where the Applet was loaded
    // 1234 is the port used
    // myInstance is where my data is

    public void init(){
    makeConnection(serverAddress);
    }

    public void makeConnection(String svr) {
    try {
    System.out.println(\"Loading ... \" + driverUsed);
    driver =
    (Driver)Class.forName(driverUsed).newInstance();
    System.out.println(\"Connecting ... \" + svr);
    conn =
    DriverManager.getConnection(svr);
    System.out.println(\"Ready.\"
    }
    catch (Exception e) {
    e.printStackTrace();
    }
    }
    }


    Please read the tutorial below to understand how this works...

    http://www.caucho.com/products/resin/ref/db-config.xtp


  3. #3
    panickiller is offline Junior Member Array
    Join Date
    Jul 2004
    Answers
    2

    Can any know SQL Server connection in java (JDBC)

    I need it immediately. Please, help me.


    ok bye..bye.bye.


  4. #4
    panickiller is offline Junior Member Array
    Join Date
    Jul 2004
    Answers
    2

    MSSQL Database connectivity in JDBC?

    Can any one know the MSSQL database connection in JDBC. If there is? help me


  5. #5
    kalareddy Guest
    Here are few links.....

    http://www.awprofessional.com/articl...&seqNum=6&rl=1

    e236. Connecting to a MySQL Database
    This example connects to a MySQL database using the MM JDBC driver for MySQL. You need to have an account in MySQL database to run this example. To create an account, you can connect to MySQL database on your platform as root, and run the following command:
    mysql> GRANT ALL PRIVILEGES ON *.* TO username@localhost
    IDENTIFIED BY 'password' WITH GRANT OPTION;


    Connection connection = null;
    try {
    // Load the JDBC driver
    String driverName = "org.gjt.mm.mysql.Driver"; // MySQL MM JDBC driver
    Class.forName(driverName);

    // Create a connection to the database
    String serverName = "localhost";
    String mydatabase = "mydatabase";
    String url = "jdbc:mysql://" + serverName + "/" + mydatabase; // a JDBC url
    String username = "username";
    String password = "password";
    connection = DriverManager.getConnection(url, username, password);
    } catch (ClassNotFoundException e) {
    // Could not find the database driver
    } catch (SQLException e) {
    // Could not connect to the database
    }


  6. #6
    kaatamraju is offline Junior Member Array
    Join Date
    Dec 2005
    Answers
    2

    oracle data base connectvity

    import java.sql.*;
    class Appl
    {
    public static void main(String args[])throws Exception
    {
    Driver d=new oracle.jdbc.driver.OracleDriver();
    //register to driver
    DriverManager.registerDriver(d);
    //connect to oracle data base
    Connection c=DriverManager.getConnection("jdbcracle:thin:@localhost:1521rcl",scott","tiger");
    Sysem.out.println("connecting to Oracle Database..........");
    Sysem.out.println("connected to Oracle Database");
    }
    }


    •    Sponsored Ads



Latest Article

Network Security Risk Assessment and Measurement

Read More...