Results 1 to 6 of 6
  1. #1
    subash is offline Member
    Join Date
    Mar 2008
    Posts
    1
    Rep Power
    0

    Default connection problem

    Hi Friends this is my code to connect to database oracle10g but i am gettin error when java command the error is invalid oracle url specified can anybody solve this problem






    import java.sql.*;
    import java.lang.*;
    import java.io.*;

    public class condb
    {
    public static void main (String args[]) throws SQLException
    {
    try{
    Class.forName("oracle.jdbc.driver.OracleDriver");
    Connection con=DriverManager.getConnection("jdbc:oracle:thin@//localhost:1521:XE","SYSTEM","tiger");
    System.out.println("connected");
    }
    catch(Exception e)
    {
    System.out.println(e);
    }
    }
    }

  2. #2
    rico16135 is offline Member
    Join Date
    Apr 2008
    Posts
    28
    Rep Power
    0

    Default

    What is with people using the DriverManager?

    JDBC is recommending that the DataSource interface should be used to create database connection objects instead of using the DriverManager class.

    Implementations of the DataSource Interface

  3. #3
    javarishi is offline Member
    Join Date
    Apr 2008
    Posts
    91
    Rep Power
    0

    Default

    The database params can be given as a url. The format of url is

    jdbc:oracle:<drivertype>:@<hostname>:<port>:<datab ase_sid>

    In your case just replace the values as
    Connection con=DriverManager.getConnection("jdbc:oracle:thin@ localhost:1521:XE","SYSTEM","tiger");

    Try It Out.

  4. #4
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,372
    Blog Entries
    1
    Rep Power
    20

  5. #5
    javarishi is offline Member
    Join Date
    Apr 2008
    Posts
    91
    Rep Power
    0

    Default

    Yaah Eranga, The space need to be deleted. No Space between @ and

    localhost. Thanks.

  6. #6
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,372
    Blog Entries
    1
    Rep Power
    20

Similar Threads

  1. Replies: 5
    Last Post: 11-08-2008, 06:15 AM
  2. Sql server connection problem
    By tanvirtonu in forum JDBC
    Replies: 1
    Last Post: 03-31-2008, 12:46 PM
  3. no connection
    By even in forum JDBC
    Replies: 15
    Last Post: 01-02-2008, 01:50 PM
  4. Java Serevr Connection Problem
    By virendra_agarwal in forum JavaServer Faces (JSF)
    Replies: 0
    Last Post: 12-19-2007, 12:43 PM
  5. JDBC driver connection problem
    By creativehacker in forum JDBC
    Replies: 3
    Last Post: 07-10-2007, 09:58 PM

Posting Permissions

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