RE: getting exception when trying to close connection

2002-06-12 Thread Christian J. Dechery

I read in the javadoc of the .close() method, that when the garbage collector runs, it 
closes the connections.
 
Well, this isn't working obviously... the thing that's keeping me from solving the 
problem is the frequency it happens... I can't understand why a connection can't be 
closed... I know of no timeouts set on oracle,and if it had... the connection AND the 
socket would be closed, don't u think? And I still have dozens of open INACTIVE 
connections on oracle...
 
A timeout on the Connection obj is also hard to believe... even because when I 
debugged it with a page opening 10 connections (just for testing, I don't have such a 
page)... 3 of them didn't close... and it was not the last three... just some random 
conns... 
 
and I guess when the finalize() method runs, its because there's no use for that 
object (in this case the DAO) anymore, right? So what would cause the exception? I'll 
try to focus on the booleans, but I don't think it'll help, since everytime I debugged 
it, the error is always on the con.close(), meaning the booleans are ok.
 
I'm hopeless!
 
 
.:| Christian J. Dechery
.:| FINEP - Depto. de Sistemas
.:| [EMAIL PROTECTED]
.:| (21) 2555-0332

 [EMAIL PROTECTED] 11/06/02 18:17  
OK well, a couple answers first. The socket that is being referred to is the 
underlying (usually tcp/ip) socket that your driver uses to connect to the 
database. A connection is an abstraction from what the implementation socket 
is. A couple things could be happening with your oracle driver. First, there 
can be an inactive timeout set on your oracle database, where connections 
are closed after a timeout period to free up resources. You would get the 
same error if for instance the server on the other end lost power, and 
therefore closed the connection by being turned off. The other thing is, 
your driver could have a timeout set. I haven't used the oracle driver 
extensively, so i'm not really sure how you configure it. Look in the docs. 
The other thing you want to do is separate out those three boolean 
statements so you can determine which one is failing. Checking for null is 
not going to throw the exception so pretty much focus on your last two. (and 
look at your driver configuration docs) you may want to try this method 
instead. 
static Connection getConnection(String url, Properties info); 
//Attempts to establish a connection to the given database URL. 
In properties, you can specify driver settings. 

Zak 

-Original Message- 
From: Christian J. Dechery [ mailto:[EMAIL PROTECTED]] 
Sent: Tuesday, June 11, 2002 12:03 PM 
To: [EMAIL PROTECTED] 
Subject: RE: getting exception when trying to close connection 


ok... there you go: 

public DAOFundos(Esquema esq) { 

if( esq==null ) { 
esq = esquemaDefault; 
} 

try { 
Class.forName( esq.getDriver() ); 
con = DriverManager.getConnection(esq.getUrl(), esq.getUser(), 
esq.getPassword()); 
} 
catch(ClassNotFoundException cnf) { 
System.out.println (Erro: driver nao encontrado! +cnf.getMessage()); 
} 
catch(SQLException sql) { 
System.out.println(Erro ao obter conexão! +sql.getMessage() ); 
} 
} 

this is the code for the default constructor... in this case the class 
Esquema contains info about: drivers, user, url and pwd. 
the driver is always oracle.jdbc.driver.OracleDriver 

thanks again 


.:| Christian J. Dechery 
.:| FINEP - Depto. de Sistemas 
.:| [EMAIL PROTECTED] 
.:| (21) 2555-0332 

 [EMAIL PROTECTED] 11/06/02 16:03  
It would be halpful to see the declaration of con, and the type of driver 
you are using 


-Original Message- 
From: Christian J. Dechery [ mailto:[EMAIL PROTECTED]] 
Sent: Tuesday, June 11, 2002 11:41 AM 
To: [EMAIL PROTECTED] 
Subject: getting exception when trying to close connection 


I know my implementation isn't the best there is... take a look at this 
code: 

protected void finalize() 

try 

if( con!=null  !con.isClosed()  con.getAutoCommit() ) 

con.close(); 
} 
} 
catch(SQLException sqle) 

System.out.println([+this.getClass().getName()+] Não foi possível 
fechar a conexão. +sqle.toString()+\n); 
// sqle.printStackTrace(); 
} 
} 

that's what I use to TRY to close all connections... this code is in my DAO 
class. Sometimes I have up to four DAO classes instantiated in a single 
JSP... I debugged it... at least one always fails to close giving me this 
exception: I/O error: socket closed 

what does that mean? what socket? And why did all the other connections 
closed and this didn't? 

.:| Christian J. Dechery 
.:| FINEP - Depto. de Sistemas 
.:| [EMAIL PROTECTED] 
.:| (21) 2555-0332 



-- 
To unsubscribe, e-mail:  mailto:[EMAIL PROTECTED] 
 
For additional commands, e-mail:  
mailto:[EMAIL PROTECTED]  





-- 
To unsubscribe, e-mail:  mailto:[EMAIL PROTECTED]  
For additional commands, e-mail:  mailto:[EMAIL PROTECTED]  






RE: getting exception when trying to close connection

2002-06-11 Thread Zachary Kuhn

It would be halpful to see the declaration of con, and the type of driver
you are using


-Original Message-
From: Christian J. Dechery [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, June 11, 2002 11:41 AM
To: [EMAIL PROTECTED]
Subject: getting exception when trying to close connection


I know my implementation isn't the best there is... take a look at this
code:

 protected void finalize() {
  try {
   if( con!=null  !con.isClosed()  con.getAutoCommit() ) {
con.close();
   }
  }
  catch(SQLException sqle) {
   System.out.println([+this.getClass().getName()+] Não foi possível
fechar a conexão. +sqle.toString()+\n);
//   sqle.printStackTrace();
  }
 }

that's what I use to TRY to close all connections... this code is in my DAO
class. Sometimes I have up to four DAO classes instantiated in a single
JSP... I debugged it... at least one always fails to close giving me this
exception: I/O error: socket closed

what does that mean? what socket? And why did all the other connections
closed and this didn't?

.:| Christian J. Dechery
.:| FINEP - Depto. de Sistemas
.:| [EMAIL PROTECTED]
.:| (21) 2555-0332



--
To unsubscribe, e-mail:   mailto:[EMAIL PROTECTED]
For additional commands, e-mail: mailto:[EMAIL PROTECTED]




RE: getting exception when trying to close connection

2002-06-11 Thread Christian J. Dechery

ok... there you go:
 
  public DAOFundos(Esquema esq) {
 
  if( esq==null ) {
   esq = esquemaDefault;
  }
 
 try {
   Class.forName( esq.getDriver() );
  con = DriverManager.getConnection(esq.getUrl(), esq.getUser(), 
esq.getPassword());
 }
 catch(ClassNotFoundException cnf) {
  System.out.println (Erro: driver nao encontrado! +cnf.getMessage());
 }
 catch(SQLException sql) {
  System.out.println(Erro ao obter conexão! +sql.getMessage() );
 }
}

this is the code for the default constructor... in this case the class Esquema 
contains info about: drivers, user, url and pwd.
the driver is always oracle.jdbc.driver.OracleDriver
 
thanks again
 
 
.:| Christian J. Dechery
.:| FINEP - Depto. de Sistemas
.:| [EMAIL PROTECTED]
.:| (21) 2555-0332

 [EMAIL PROTECTED] 11/06/02 16:03  
It would be halpful to see the declaration of con, and the type of driver 
you are using 


-Original Message- 
From: Christian J. Dechery [ mailto:[EMAIL PROTECTED]] 
Sent: Tuesday, June 11, 2002 11:41 AM 
To: [EMAIL PROTECTED] 
Subject: getting exception when trying to close connection 


I know my implementation isn't the best there is... take a look at this 
code: 

protected void finalize() { 
try { 
if( con!=null  !con.isClosed()  con.getAutoCommit() ) { 
con.close(); 
} 
} 
catch(SQLException sqle) { 
System.out.println([+this.getClass().getName()+] Não foi possível 
fechar a conexão. +sqle.toString()+\n); 
// sqle.printStackTrace(); 
} 
} 

that's what I use to TRY to close all connections... this code is in my DAO 
class. Sometimes I have up to four DAO classes instantiated in a single 
JSP... I debugged it... at least one always fails to close giving me this 
exception: I/O error: socket closed 

what does that mean? what socket? And why did all the other connections 
closed and this didn't? 

.:| Christian J. Dechery 
.:| FINEP - Depto. de Sistemas 
.:| [EMAIL PROTECTED] 
.:| (21) 2555-0332 



-- 
To unsubscribe, e-mail:  mailto:[EMAIL PROTECTED]  
For additional commands, e-mail:  mailto:[EMAIL PROTECTED]  






RE: getting exception when trying to close connection

2002-06-11 Thread Zachary Kuhn

OK well, a couple answers first. The socket that is being referred to is the
underlying (usually tcp/ip) socket that your driver uses to connect to the
database. A connection is an abstraction from what the implementation socket
is. A couple things could be happening with your oracle driver. First, there
can be an inactive timeout set on your oracle database, where connections
are closed after a timeout period to free up resources. You would get the
same error if for instance the server on the other end lost power, and
therefore closed the connection by being turned off. The other thing is,
your driver could have a timeout set. I haven't used the oracle driver
extensively, so i'm not really sure how you configure it. Look in the docs.
The other thing you want to do is separate out those three boolean
statements so you can determine which one is failing. Checking for null is
not going to throw the exception so pretty much focus on your last two. (and
look at your driver configuration docs) you may want to try this method
instead.
static Connection getConnection(String url, Properties info);
  //Attempts to establish a connection to the given database URL.
In properties, you can specify driver settings.

Zak

-Original Message-
From: Christian J. Dechery [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, June 11, 2002 12:03 PM
To: [EMAIL PROTECTED]
Subject: RE: getting exception when trying to close connection


ok... there you go:

  public DAOFundos(Esquema esq) {

  if( esq==null ) {
   esq = esquemaDefault;
  }

 try {
   Class.forName( esq.getDriver() );
  con = DriverManager.getConnection(esq.getUrl(), esq.getUser(),
esq.getPassword());
 }
 catch(ClassNotFoundException cnf) {
  System.out.println (Erro: driver nao encontrado! +cnf.getMessage());
 }
 catch(SQLException sql) {
  System.out.println(Erro ao obter conexão! +sql.getMessage() );
 }
}

this is the code for the default constructor... in this case the class
Esquema contains info about: drivers, user, url and pwd.
the driver is always oracle.jdbc.driver.OracleDriver

thanks again


.:| Christian J. Dechery
.:| FINEP - Depto. de Sistemas
.:| [EMAIL PROTECTED]
.:| (21) 2555-0332

 [EMAIL PROTECTED] 11/06/02 16:03 
It would be halpful to see the declaration of con, and the type of driver
you are using


-Original Message-
From: Christian J. Dechery [ mailto:[EMAIL PROTECTED]]
Sent: Tuesday, June 11, 2002 11:41 AM
To: [EMAIL PROTECTED]
Subject: getting exception when trying to close connection


I know my implementation isn't the best there is... take a look at this
code:

protected void finalize()

try

if( con!=null  !con.isClosed()  con.getAutoCommit() )

con.close();
}
}
catch(SQLException sqle)

System.out.println([+this.getClass().getName()+] Não foi possível
fechar a conexão. +sqle.toString()+\n);
// sqle.printStackTrace();
}
}

that's what I use to TRY to close all connections... this code is in my DAO
class. Sometimes I have up to four DAO classes instantiated in a single
JSP... I debugged it... at least one always fails to close giving me this
exception: I/O error: socket closed

what does that mean? what socket? And why did all the other connections
closed and this didn't?

.:| Christian J. Dechery
.:| FINEP - Depto. de Sistemas
.:| [EMAIL PROTECTED]
.:| (21) 2555-0332



--
To unsubscribe, e-mail:  mailto:[EMAIL PROTECTED]

For additional commands, e-mail: 
mailto:[EMAIL PROTECTED] 





--
To unsubscribe, e-mail:   mailto:[EMAIL PROTECTED]
For additional commands, e-mail: mailto:[EMAIL PROTECTED]