JDBC Oracle

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • mikaelD
    New Member
    • Oct 2008
    • 8

    #1

    JDBC Oracle

    Hello

    I've been trying to connect to an oracle db for the last two days and that doesn't work. I solved all the problems concerning configuration and drivers but now my script just freezes at the getConnection command and does not get past it. I receive neither error nor exception. Here is my source :

    Code:
    import java.sql.*;
    
    public class testOra
    	{
    	public static void main(String[] args)
    		{
    		try
    			{
    			Class.forName("oracle.jdbc.driver.OracleDriver");
    			 }
    		catch (Exception e)
    			{ }
    		String url = "jdbc:oracle:oci:@86.64.1.51:1521";
    		String login = "----"; 
    		String password = "-----";
    		try{
    		Connection connection = DriverManager.getConnection(url,login,password);
    		//interaction avec la base
    		}
    		catch(SQLException sqle){
    		System.out.println(sqle);
    		}
    		finally{
    			System.out.println("Cool !");
    			}
    
    		}  
    
    	}
    Thanks for help
  • r035198x
    MVP
    • Sep 2006
    • 13225

    #2
    Don't write code like this
    [CODE=java]catch (Exception e)
    { }[/CODE]

    That simply swallows up any exceptions and tells no one about it.

    Use [CODE=java]catch (Exception e) {
    e.printStackTra ce();
    }[/CODE] as a minimum to see what exceptions (if any) are thrown.

    Comment

    • mikaelD
      New Member
      • Oct 2008
      • 8

      #3
      Yes You're right, I shouldn't do such things, thats corrected but the problem is still there.

      Thanks for help

      Comment

      • r035198x
        MVP
        • Sep 2006
        • 13225

        #4
        What happens when you run it now? Nothing is printed on the console?

        Comment

        • mikaelD
          New Member
          • Oct 2008
          • 8

          #5
          Hello,

          Nothing happens, the program does not end but I'm on Stand by.

          Comment

          • NawazAhmed
            New Member
            • Feb 2008
            • 36

            #6
            Try this, I hope this will help u out.
            Code:
            public class testOra 
                { 
                public static void main(String[] args) 
                    { 
                    try 
                        { 
                        Class.forName("oracle.jdbc.driver.OracleDriver").newInstance();
                         } 
                    catch (Exception e) 
                        { } 
                    String url = "jdbc:oracle:thin:@86.64.1.51:1521:databaseName"; 
                    String login = "----";  
                    String password = "-----"; 
                    try{ 
                    Connection connection = DriverManager.getConnection(url,login,password); 
                    //interaction avec la base 
                    } 
                    catch(SQLException sqle){ 
                    System.out.println(sqle); 
                    } 
                    finally{ 
                        System.out.println("Cool !"); 
                        } 
              
                    }   
              
                }

            Comment

            • mikaelD
              New Member
              • Oct 2008
              • 8

              #7
              Hello,

              Thanks for all the help.
              It seems like the problem came from the oci driver. Using thin driver simply solves everything (but what are the consequences ? That remains to be found ...)

              Comment

              Working...