| Oracle FAQ | Your Portal to the Oracle Knowledge Grid | |
Home -> Community -> Usenet -> c.d.o.misc -> JDBC Oracle Driver ERROR?
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"
It's OK, because when you recreate connection ( e.g. put in network cable )
and then press button 'connect' everything is OK - you have again connection
to database.
Problem is:
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.*;
public class Test extends Frame implements ActionListener {
static String url = "jdbc:oracle:thin:@host.com.pl:1521:sid1";
static String driver = "oracle.jdbc.driver.OracleDriver";
static String user ="scott";
static String pass = "tiger";
Label label = null;
Button button = null;
public static void main(String args[])
{
new Test();
}
private void connect()
{
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!!!");
Test()
{
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();
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 - 02:48:59 CDT
![]() |
![]() |