DBAsupport.com Forums - Powered by vBulletin
Results 1 to 4 of 4

Thread: Connecting to Local Dabase from Java

  1. #1
    Join Date
    Nov 2001
    Location
    UK
    Posts
    152
    I am writing a JAVA program which accesses a database on the same machine as the program. To avoid hard-coding a user name and password, I was trying to log on using the default username feature (i.e. connect as "/"). Can this be done with JAVA ? Most of the drivers seem to use a network-style connection. Is there one which can do a direct connection to a local database ?

  2. #2
    Join Date
    May 2002
    Posts
    27

    Yeah

    I am not vert clear about your problem but we genarlly give connection to the database in this manner

    Class.forName("oracle.jdbc.driver.OracleDriver");
    con = DriverManager.getConnection("jdbcracle:thin:@machinename(you can give local host here if you r database is running on the local machine ort number :Host String","user name","passward");

    I donot think so that we can use some default value for that.But i am not very sure on this.

    Which driver you are using ? and please be more clear about your problem so that i will see if i can help you in this.

  3. #3
    Join Date
    Apr 2001
    Location
    Czechia
    Posts
    712
    Originally posted by Scorby
    Is there one which can do a direct connection to a local database ?
    It's possible to use the oci8 driver for creating a connection to a local DB. Works fine for me on 817/Solaris.
    I saw some benchmarks proving it's a bit faster than thin driver:

    conn = DriverManager.getConnection ("jdbc:oracle:oci8:@","username","password");

    Ales

  4. #4
    Join Date
    Dec 2001
    Location
    UK
    Posts
    1,684
    If the Java was loaded into the DB and run via JServer you could use the default connection:

    Connection conn = null;
    OracleDriver ora = new OracleDriver();
    conn = ora.defaultConnection();

    This is faster than connecting via a conventional driver.

    For a crappy example look at:

    http://www.oracle-base.com/Articles/...heDatabase.asp

    Cheers
    Tim...
    OCP DBA 7.3, 8, 8i, 9i, 10g, 11g
    OCA PL/SQL Developer
    Oracle ACE Director
    My website: oracle-base.com
    My blog: oracle-base.com/blog

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Click Here to Expand Forum to Full Width