473,322 Members | 1,523 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,322 software developers and data experts.

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 :

Expand|Select|Wrap|Line Numbers
  1. import java.sql.*;
  2.  
  3. public class testOra
  4.     {
  5.     public static void main(String[] args)
  6.         {
  7.         try
  8.             {
  9.             Class.forName("oracle.jdbc.driver.OracleDriver");
  10.              }
  11.         catch (Exception e)
  12.             { }
  13.         String url = "jdbc:oracle:oci:@86.64.1.51:1521";
  14.         String login = "----"; 
  15.         String password = "-----";
  16.         try{
  17.         Connection connection = DriverManager.getConnection(url,login,password);
  18.         //interaction avec la base
  19.         }
  20.         catch(SQLException sqle){
  21.         System.out.println(sqle);
  22.         }
  23.         finally{
  24.             System.out.println("Cool !");
  25.             }
  26.  
  27.         }  
  28.  
  29.     }
  30.  
Thanks for help
Oct 30 '08 #1
6 2102
r035198x
13,262 8TB
Don't write code like this
Expand|Select|Wrap|Line Numbers
  1. catch (Exception e)
  2.             { }
That simply swallows up any exceptions and tells no one about it.

Use
Expand|Select|Wrap|Line Numbers
  1. catch (Exception e) {
  2. e.printStackTrace();
  3.  }
as a minimum to see what exceptions (if any) are thrown.
Oct 30 '08 #2
Yes You're right, I shouldn't do such things, thats corrected but the problem is still there.

Thanks for help
Oct 30 '08 #3
r035198x
13,262 8TB
What happens when you run it now? Nothing is printed on the console?
Oct 30 '08 #4
Hello,

Nothing happens, the program does not end but I'm on Stand by.
Oct 30 '08 #5
Try this, I hope this will help u out.
Expand|Select|Wrap|Line Numbers
  1. public class testOra 
  2.     { 
  3.     public static void main(String[] args) 
  4.         { 
  5.         try 
  6.             { 
  7.             Class.forName("oracle.jdbc.driver.OracleDriver").newInstance();
  8.              } 
  9.         catch (Exception e) 
  10.             { } 
  11.         String url = "jdbc:oracle:thin:@86.64.1.51:1521:databaseName"; 
  12.         String login = "----";  
  13.         String password = "-----"; 
  14.         try{ 
  15.         Connection connection = DriverManager.getConnection(url,login,password); 
  16.         //interaction avec la base 
  17.         } 
  18.         catch(SQLException sqle){ 
  19.         System.out.println(sqle); 
  20.         } 
  21.         finally{ 
  22.             System.out.println("Cool !"); 
  23.             } 
  24.  
  25.         }   
  26.  
  27.     } 
  28.  
Oct 30 '08 #6
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 ...)
Nov 3 '08 #7

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: Rahul | last post by:
I am getting the following exception when accessing one of my tables. java.lang.reflect.InvocationTargetException: java.lang.ArrayIndexOutOfBoundsException at...
0
by: Prashant Kumar | last post by:
Hi: I get the following exception from oracle. It seems to be happening during a rollback of a transaction, while doing an executeBatch() Has anyone seen this before ? Thanks much!...
1
by: William Brasky | last post by:
All - The project I'm on requires a secure connection between our Java J2EE application (running on BEA WebLogic 8.1) and Oracle 9i via JDBC. As I understand it, both the thin and thick Oracle...
1
by: Axel Dachtler | last post by:
Hello, my Java-program can't load the JDBC driver. I always get a java.lang.NoClassDefFoundError when I run it. The JDBC Driver is in the directory: C:\programs\ora92\jdbc\lib I think I...
1
by: Achille Carette | last post by:
Hello all, I noticed a difference in the explain plans between JDBC using bind variables (PreparedStatement) and SQLPlus for the same query. The query made through JDBC using bind variables...
1
by: Howie Goodell | last post by:
Hello -- I am trying to optimise a JDBC connection and an Oracle 9i database for reading millions of records at a time to a 1 Gig PC running Win2K or XP. Two questions: 1. Does anyone have...
2
dzenanz
by: dzenanz | last post by:
Calling a stored procedure from Java with ojdbc 1.4 corrupts (converts to ¿) unicode characters that are not contained in DB's current charset. Calling this proc from C# works as expected (all...
0
by: Jim Kennedy | last post by:
ALL DDL does a commit. Hence Drop Table movies; issues a commit. True you don't issue a commit and the driver does not issue a commit, but the server does for all DDL. That is probably where...
1
by: Fred | last post by:
Hi, I'm new to Oracle. I've got 9i setup on a Windows 2000 machine, named "Jackie", and using the userid of "Scott" with password "Tiger", I can do SQLPLus commands to my hearts content. From a...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.