0

I am working with a swing application and the initial part of the application is "user authentication" ..for that module i want to authenticate(verify) the user but the problem is that my database is remotly located with different port(not 1521). everytime i try to connect through some easy and simple jdbc,a well designed exception occures to decorate my console something like this

"SEVERE: null java.sql.SQLException: Io exception: The Network Adapter could not establish the connection at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:112) at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:146) at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:255) at oracle.jdbc.driver.T4CConnection.logon(T4CConnection.java:387) at oracle.jdbc.driver.PhysicalConnection.(PhysicalConnection.java:414)"

The Programmers who have worked with swings specially when they made a tool for some webservices might have fallen into the same category..please give it a look and thought.

4 Answers 4

1

using simple JDBC you can connect to remote oracle DB.

Sign up to request clarification or add additional context in comments.

6 Comments

java.sql.SQLException: Io exception: The Network Adapter could not establish the connection
i tried to do that but "java.sql.SQLException: Io exception: The Network Adapter could not establish the connection" is there every time
@Aman , can you ping your remote Oracle DB Server ? can you please update your question with stacktrace , your code
i am able to ping remote oracle db server. the code is like that :String url = "jdbc:oracle:thin:@" + serverName + ":" + portNumber + ":" + sid; String username = "AMNHU"; String password = "bmtmkc"; try { connection = DriverManager.getConnection(url, username, password); System.out.println("Connected*****************************"); } catch (SQLException ex) { Logger.getLogger(Test.class.getName()).log(Level.SEVERE, null, ex); } i think there is a problem of port
Please share some more ideas..i've got stuck ther only.trying to find the best but everytime its ZERO..
|
1

LDAP is essentially a big Map allowing you to look things up. You don't use that to talk to an Oracle database, but a JDBC-driver.

You will need one that corresponds to your Oracle database, and you have two options:

  • thin: This one is in pure Java and you need to use the IP-number or DNS-name of the database server.
  • thick: This one calls the same libraries as SQLPLUS so you can use the same database names as you can in SQLPLUS.

Also note that the Swing application needs to be able to actually reach the database across the network for this to work. Usually Oracle runs on port 1521. This frequently means firewall rules for any non-trivial setup.

1 Comment

Very Appreciative suggestion. Thnx !! is there any remedy for that.like proxy setting etc..
0

This is clearly a network problem, meaning that you cannot access the database through the network or maybe the provided url is invalid. Also, make sure that you use something like this:

String driverName = "oracle.jdbc.driver.OracleDriver"; 
Class.forName(driverName);
connection = DriverManager.getConnection(url, username, password); 

The Light Directory Access Protocol is used for authenticating users into the application, not for connecting to the database.

3 Comments

I dont know much about LDAP but want to know about it,i went through many tutorials and finally seted my mind up with respect to LDAP...Please share some code where i can authenticate my user with ldap using a swing application. Thnaks in advance
I don't have code using LDAP but I can suggest you a framework that will ease your pain using LDAP. It is called Apache Shiro. Maybe you can take a look and see if it helps. Cheers
Also, you can try Apache Directory Studio which is a LDAP browser and directory client.
0

I am also having this same problem. When connecting from Swing application framework alone, this error is coming. I am able to connect to the database from PLSQL Developer. I am also able to connect to db using another java desktop application, which is not based on "SwingAppliation Framework". I am trying to connect to database from Task classes, and it fails. In The other application which works, I am using normal java class. In both the application I am using Hibernate.

1 Comment

My issue got resolved, after by-passing proxy server for the db servers. The other applications doesnot use proxy server so they were working. But when using Swing Application Framework, it was sending requests to proxy server and it was blocking communication.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.