Results 1 to 3 of 3
  1. #1
    rohitj is offline Member
    Join Date
    Sep 2011
    Location
    Bangalore
    Posts
    8
    Rep Power
    0

    Unhappy Not able to connect to the database with my JDBC program

    I started working on JDBC. Im using the Oracle 10G software as my database and NetBeans as my IDE. Im making use of type-4 driver for my jdbc operations.

    Here goes my project...

    1) I created a table using oracle 10g.

    2) Included the required library. (path : C:\oraclexe\app\oracle\product\10.2.0\server\jdbc\ lib\ojdbc14_g.jar)

    3) Typed a program like the one below to connect to the database where i have created the table.....


    package jdbc;

    import java.sql.DriverManager;
    import java.sql.*;

    public class db_connection_test{
    public static void main(String[] args){
    try{
    Class.forName("oracle.jdbc.driver.OracleDriver");
    Connection con = DriverManager.getConnection("jdbc:oracle:thin:@loc alhost:1521","hr","hr"); // Im using a Type-4 driver.
    System.out.println("Connecton Established");
    }
    catch(Exception e){
    System.out.println("Connection cannot be established"+e);
    }
    }

    }

    4) now, if i run the above program the connection is not getting established. Im getting an exception stating " Connection cannot be establishedjava.sql.SQLException: Io exception: The Network Adapter could not establish the connection "


    So, friends i need any one of your help on these. Please do analize this problem and get me the solution for the same.....

    Regards,
    Rohit.J

  2. #2
    doWhile is offline Moderator
    Join Date
    Jul 2010
    Location
    California
    Posts
    1,641
    Rep Power
    7

    Default Re: Not able to connect to the database with my JDBC program

    The printStackTrace method of the Exception class is your friend, as is google (or your favorite web search engine) - a single search of the exception message yields several hundred thousands hits, the top ones of which contain very plausible reasons and solutions.

  3. #3
    rohitj is offline Member
    Join Date
    Sep 2011
    Location
    Bangalore
    Posts
    8
    Rep Power
    0

    Default Re: Not able to connect to the database with my JDBC program

    k thank you.. i rectified it.

Similar Threads

  1. How to connect to any database without any JDBC driver?
    By sandeep43 in forum Advanced Java
    Replies: 10
    Last Post: 05-20-2011, 11:06 AM
  2. unable to connect remote database using jdbc
    By enggvijaysingh@gmail.com in forum Advanced Java
    Replies: 1
    Last Post: 12-16-2010, 12:16 PM
  3. how to connect to database using jdbc in servelets
    By sureshmca08 in forum Java Servlet
    Replies: 2
    Last Post: 05-28-2010, 09:06 AM
  4. connect JDBC to offline database
    By nancyhung in forum JDBC
    Replies: 1
    Last Post: 04-11-2008, 11:04 PM
  5. Using JDBC to connect to ORACLE database
    By Java Tip in forum Java Tip
    Replies: 0
    Last Post: 02-10-2008, 11:27 AM

Posting Permissions

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