Forums Register Login

Problems Connecting to a database through a Swing Application

+Pie Number of slices to send: Send
Hi
I have just started learning Swing.

What I am trying to do:
Creating an application which will retrieve some data from a Oracle Database.

What I have done so far:
I am trying to connect to the Database first and I wish to proceed further once the connection is established.

PROBLEM: I am getting the following error when I run the application: java.sql.SQLException: Io exception: The Network Adapter could not establish the connection

Code:- (this is just the code for the Button Click. Filename:DesktopApplicationView.java )

private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {

// TODO add your handling code here:
String s=null;
String ret_msg;
String messg=null;
Object env_name=jComboBox1_EnvNames.getSelectedItem();
s=env_name.toString();
jTextField2.setText(s);
Connection conn;//This is the point from where I feel the real problem begins

try
{
Class.forName("oracle.jdbc.driver.OracleDriver");
conn=DriverManager.getConnection("jdbc:oracle:thin:@10.*.*.*:1523:oron","user","pass");

ret_msg="Connection to the DB Established";


}
catch (ClassNotFoundException c)
{
ret_msg=c.toString();
System.out.println(ret_msg);
}
catch (SQLException sq_ex)
{
ret_msg=sq_ex.toString();
System.out.println(ret_msg);
}


jTextField3.setText(ret_msg); //I am expecting it to return: 'Connection to the DB Established' but instead it returns the error message.

}


Some Facts:-
*The database I am trying to connect to is huge. Is that a problem? I tried connecting to the database through a standalone program and it worked.
*I tried to make a separate class to do all the database related work and call it through this class but it throws the same error.
*I am new to Swing...just started yesterday...so anything which makes you say

<removed inappropriate content>






[jc: removed four letter words from the post. Please mind your language]
+Pie Number of slices to send: Send
This is really about JDBC, not swing. So I'm going to move this to the JDBC forum.
+Pie Number of slices to send: Send
Hi Shantanu,

Please use code tags. Makes it easier to read your code.
You can edit your post by clicking on the Edit icon at its right top.

+Pie Number of slices to send: Send
Re-posting with code tags:-

Hi
I have just started learning Swing.

What I am trying to do: Creating an application which will retrieve some data from a Oracle Database.

What I have done so far: I am trying to connect to the Database first and I wish to proceed further once the connection is established.

PROBLEM: I am getting the following error when I run the application: java.sql.SQLException: Io exception: The Network Adapter could not establish the connection

Code:- (this is just the code for the Button Click. Filename:DesktopApplicationView.java )




Some Facts:-
*The database I am trying to connect to is huge. Is that a problem? I tried connecting to the database through a standalone program and it worked.
*I tried to make a separate class to do all the database related work and call it through this class but it throws the same error.
He was giving me directions and I was powerless to resist. I cannot resist this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com


reply
reply
This thread has been viewed 2252 times.
Similar Threads
connecting to db2 using net driver
Unable to establish a network connection
java with mysql
problem with MySQL driver
problem with MySQL driver
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 28, 2024 11:44:01.