Connection with a remote database using java swing application

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.


使用简单的JDBC你可以连接到远程oracle数据库。


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.


    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.

    链接地址: http://www.djcxy.com/p/61696.html

    上一篇: Oracle DB:java.sql.SQLException:关闭连接

    下一篇: 使用java swing应用程序连接远程数据库