File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes JDBC and the fly likes Exception while connecting to an Oracle database Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC
Bookmark "Exception while connecting to an Oracle database" Watch "Exception while connecting to an Oracle database" New topic
Author

Exception while connecting to an Oracle database

Steli Niculescu
Greenhorn

Joined: Jul 14, 2009
Posts: 14
I have to do a small JDBC program that works with an Oracle 10g express edition installed on my computer.
I downloaded the 10.2.0.4 driver (ojdbc14.jar) from here, and i have the
following code :


I get the exception
java.sql.SQLException: Io exception: The Network Adapter could not establish the connection
at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:112)
, even if the service is started.

What am i doing wrong?
Shailesh Chandra
Ranch Hand

Joined: Aug 13, 2004
Posts: 1081

  • you should use driver oracle.jdbc.driver.OracleDriver
  • since you are passing user name/password as arguement so no need to include same in URL

    static final String DB_URL = jdbc:oracle:thin:@localhost:1521:orcl;



  • Shailesh


    Gravitation cannot be held responsible for people falling in love ~ Albert Einstein
    Steli Niculescu
    Greenhorn

    Joined: Jul 14, 2009
    Posts: 14
    It works now, thank you.
     
    I agree. Here's the link: http://aspose.com/file-tools
     
    subject: Exception while connecting to an Oracle database