Can't connect to Oracle DB via JDBC on java desktop app?

There are not enough debug prints or catch statements Try catching both general Exception and Throwable, see if that adds data If you don't have a debugger, add debug prints on every line so you know exactly where you are If you have the ojdbc6. Jar, try adding this right before DriverManager.getConnection.

Up vote 0 down vote favorite share g+ share fb share tw.

I was trying to create a very simple app where at loading the main window the program connects to the DB. If I comment the part of the connection to the DB it works fine. The app shows no error, throws no exception, so I cannot figure out what's wrong.

I post my code: public final class Database { private final String dbURL = "jdbc:oracle:thin:@" + dbHost + ":" + dbPort + ":" + dbService; private final String dbDriver = "oracle.jdbc.driver. OracleDriver"; private Connection connection = null; public Database() { try { System.out. Println("Aqui 1"); Class.

ForName(dbDriver); } catch (ClassNotFoundException ex) { Logger. GetLogger(Database.class.getName()). Log(Level.

SEVERE, null, ex); } } private void connect() { System.out. Println("Dentro"); try { connection = DriverManager. GetConnection(dbURL, dbUser, dbPass); } catch (SQLException ex) { Logger.

GetLogger(Database.class.getName()). Log(Level. SEVERE, null, ex); } } private void disconnect() { try { connection.close(); } catch (SQLException ex) { Logger.

GetLogger(Database.class.getName()). Log(Level. SEVERE, null, ex); } } public void numeroErrores(String dependencia){ System.out.

Println("Hola"); connect(); disconnect(); System.out. Print("Adios"); } } the dbUser, dbPass, dbHost, dbPort, dbService are set to their correct value, I've checked and rechecked them, also I am sure I've added the correct jar file of the oracle-jdbc. It kind of hangs (I say kind of 'cause no error no nothing is shown but the System.out.

Println I put there) when calling the connect() method. Any idea? Java oracle jdbc database-connection link|improve this question asked Feb 20 at 16:37BRabbit273038 89% accept rate.

We need some sort of exception. – Max Feb 20 at 16:41 There's no exception, no nothing, I'm working in NetBeans and used its debugger to see if I could see something but nope... Any idea to see what's wrong? Something I could look into the debugging to post it here?

– BRabbit27 Feb 20 at 16:46 Are you sure the port is open (Firewall - local or somewhere in between) and the listener accepts remote connections from your host? I often use java based query tools to make sure remote connections via java work. – hburde Feb 21 at 14:12.

There are not enough debug prints or catch statements Try catching both general Exception and Throwable, see if that adds data If you don't have a debugger, add debug prints on every line so you know exactly where you are If you have the ojdbc6. Jar, try adding this right before DriverManager. GetConnection: DriverManager.

RegisterDriver(new oracle.jdbc.OracleDriver()); just to make sure.

Tried with general Exception and Throwable and there aren't any messages at all. I'm using the ojdbc6. Jar and tried with the line you posted and nothing.

Using some prints I found the before connection = DriverManager.getConnection() it works fine but for some reason the program never passes that line, maybe a loop inside the getConnection() method. – BRabbit27 Feb 20 at 17:21 the timeout for the connection can be very long - up to a few minutes. You can wait 3 to 5 minutes and see if you get connection timeout.

Can you ping the db machine? – yael alfasi Feb 20 at 17:32 I'll let the app run till something (hopefully) shows. The db machine is ok I am making some queries using sqlDeveloper.

I'll post if the timeout shows. – BRabbit27 Feb 20 at 17:47 Indeed, IO Error: The Network Adapter could not establish the connection. – BRabbit27 Feb 20 at 17:50 1 this is a regular connection problem, either ip or port are wrong.

Try maybe using the server name instead of an ip, or the other way – yael alfasi Feb 20 at 17:59.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions