JDBC Oracle Driver ERROR?
Date: Fri, 28 Sep 2001 09:48:59 +0200
Message-ID: <9p1a6p$gt7$1_at_news.formus.pl>
I have problem.
This simple program create connection to database ( Oracle ).
If you press button 'connect' and program create connection and then you
break connection (e.g. physically - pull out network cable ) and then you
press button 'connect' you receive SQLException:
"java.sql.SQLException: Wyj?tek we-wy: The Network Adapter could not
establish the connection"
Problem is:
public class Test extends Frame implements ActionListener
{
static String url = "jdbc:oracle:thin:_at_host.com.pl:1521:sid1";
static String driver = "oracle.jdbc.driver.OracleDriver";
static String user ="scott";
Label label = null;
public static void main(String args[])
new Test();
private void connect()
Test()
When you haven't connection to database ( e.g. - network cable is pull out )
and then you press button 'connect' you received SQLException and
you never can create connection during work this program - you MUST RESTART
THIS PROGRAM..
Help me:
Do you known how fix this problem?
//------------------------------------------------------------------------
// simple program
//------------------------------------------------------------------------
import java.sql.*;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
static String pass = "tiger";
Button button = null;
{
}
{
try {
Class.forName(driver);
} catch (ClassNotFoundException e) {
label.setText("Can't load driver");
return;
}
try {
Connection con = DriverManager.getConnection(url, user, pass);
} catch (SQLException e) {
label.setText("Can't connect");
return;
}
label.setText("Success!!!");
}
{
super("JDBC test");
label = new Label("Status: not connected");
button = new Button("connect");
button.addActionListener(this);
this.setLayout(new BorderLayout());
this.add(label, "Center");
this.add(button, "South");
pack();
show();
}
public void actionPerformed(ActionEvent e)
{
label.setText("connecting ....");
connect();
}
}
I have:
- Java(TM) 2 SDK, Standard Edition Version 1.3.1 - Oracle 8i - classes12.zip ( 1 931 357 Kb )
Best Regards,
Tomek
Received on Fri Sep 28 2001 - 09:48:59 CEST