Results 1 to 4 of 4
  1. #1
    Join Date
    Sep 2003
    Location
    Brussel
    Posts
    52

    Unanswered: Connect to Oracle from Java

    Ok, I've been searching on this for more than 2 weeks and still didn't find an answer. I know this is in many books, but it just don't work.

    I use Oracle9i and JDeveloper9i (as my IDE). I run my application on the server JDeveloper9i provides.

    I try to connect to the database like this:

    I imported the java.sql.*; package.

    DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver());
    Connection conn = DriverMangager.getConnection("jdbcracle:thin:@localhost:1521rcl","scott","tiger");

    When I run my class, I've got no errors or warnings, but in my database there has never changed a thing (I create a table after that, but that table is never created).

    I know this isn't a Java forum, but I just wanted to know from the Oracle people if this is the right way to create a connection.

    Thanks in advance.

    PS: I know there is this site www.connectionstrings.com for all kind of connections to all kind of databases, but also there I didn't find the information necessary to solve my problem. If there are people who know other great places where I find information about connection strings, please report it in this thread.
    A good programmer is a LAZY programmer!

  2. #2
    Join Date
    Jan 2004
    Location
    Sochaux (France)
    Posts
    55
    Just one question :
    Did you make a COMMIT after your INSERT or CREATE statement.
    Default java statement is autocommit false...

  3. #3
    Join Date
    Sep 2003
    Location
    Brussel
    Posts
    52
    Never done a commit. I just execute my query.
    A good programmer is a LAZY programmer!

  4. #4
    Join Date
    Aug 2003
    Location
    Where the Surf Meets the Turf @Del Mar, CA
    Posts
    7,776
    Provided Answers: 1
    Try something along the lines of the following:
    DriverManager.registerDriver
    (new oracle.jdbc.driver.OracleDriver());
    Connection con = DriverManager.getConnection
    ("jdbcracle:thin:@think:1521:THINK1",
    "scott", "tiger");
    You can lead some folks to knowledge, but you can not make them think.
    The average person thinks he's above average!
    For most folks, they don't know, what they don't know.
    Good judgement comes from experience. Experience comes from bad judgement.

Posting Permissions

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