views:

94

answers:

3

Hello, 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.

+1  A: 

using simple JDBC you can connect to remote oracle DB.

org.life.java
java.sql.SQLException: Io exception: The Network Adapter could not establish the connection
Aman
i tried to do that but "java.sql.SQLException: Io exception: The Network Adapter could not establish the connection" is there every time
Aman
@Aman , can you ping your remote Oracle DB Server ? can you please update your question with stacktrace , your code
org.life.java
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
Aman
@Aman check firewall, port blocker, antivirus settings i would say..
org.life.java
with local database this it code is absoultely working fine..
Aman
Please share some more ideas..i've got stuck ther only.trying to find the best but everytime its ZERO..
Aman
@Aman there must be some conf. issue, try connecting that Server using another client like Sqldeveloper
org.life.java
+1  A: 

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.

Thorbjørn Ravn Andersen
Very Appreciative suggestion. Thnx !! is there any remedy for that.like proxy setting etc..
Aman
Please edit your question to include networking details.
Thorbjørn Ravn Andersen
A: 

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.

virgium03
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
Aman
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
virgium03
Also, you can try Apache Directory Studio which is a LDAP browser and directory client.
virgium03