RE: [JBoss-user] Quick JDBC question.

2003-10-11 Thread Rod Macpherson
Title: Message



It is 
certain that you are getting to the finally clause and if there are no 
SQLExceptions being logged there is nothing more you can do with that code 
snippet. Maybe there is a a bug in the release candidate? I would just 
ignore the warning unless you are really running out of connections. Might 
want to try using a basic statement rather than a prepared statement. Nothing 
wrong with what you have but unless you are reusing the same statement with a 
different bind argument each time there is no point in using a prepared 
statement. 

  
  -Original Message-From: Mike Youngstrom 
  [mailto:[EMAIL PROTECTED] Sent: Friday, October 10, 2003 10:24 
  PMTo: [EMAIL PROTECTED]Subject: RE: 
  [JBoss-user] Quick JDBC question.
  
  Thanks for the 
  tip.  I rewrote the code like you suggested and I’m still getting the 
  warning.  Any more ideas?
   
  Mike
   
  -Original 
  Message-From: 
  [EMAIL PROTECTED] 
  [mailto:[EMAIL PROTECTED] On Behalf Of Rod MacphersonSent: Thursday, October 09, 2003 7:12 
  PMTo: 
  [EMAIL PROTECTED]Subject: RE: [JBoss-user] Quick JDBC 
  question.
   
  
  I would 
  structure this as follows to make sure the ResultSet is always closed and also 
  so that you do not get a null pointer if the prepare statement 
  throws:
  
   
  
  
  blah 
  blah blah...
  
   
  
  finally
  
  {
  
      try 
  
  
      
  {
  
      
  if(result != null) 
  result.close();
  
      
  if(statement != null) 
  statement.close();
  
      
  if(connection != 
  null) connection.close();
  
      }
  
      catch(SQLException e) 
  
  
      { 
  
  
      
  logger.error("whaddup?"); 
  
      
  }
  
  }
  
   
  
   
  
-Original 
Message-From: Mike 
Youngstrom [mailto:[EMAIL PROTECTED] Sent: Thursday, October 09, 2003 5:35 
PMTo: 
[EMAIL PROTECTED]Subject: RE: [JBoss-user] Quick JDBC 
    question.
Let me 
add a little more information.
 
Version: JBoss 
3.2.2 RC3
DBServer Mysql 
4.0.15 Windows
JDBCDriver: 
Connector/J 3.0.8
 
Mike
 
-Original 
Message-From: 
[EMAIL PROTECTED] 
[mailto:[EMAIL PROTECTED] On Behalf Of Mike 
YoungstromSent: Thursday, 
October 09, 2003 10:38 AMTo: 
[EMAIL PROTECTED]Subject: [JBoss-user] Quick JDBC 
    question.
 
I’m 
fairly new to JDBC development and JBoss.  I have the following code in 
a stateless session bean.
 
    
try {
  
boolean exists;
  
prepStmt = conn.prepareStatement(USERNAME_EXISTS);
  
prepStmt.setString(1, username);
  
ResultSet result = prepStmt.executeQuery();
  
exists = result.next();
  
result.close();
  
return exists;
    
} catch (EJBException e) {
  
log.error("Error checking if username 
exists: ", e);
  
throw new EJBException(e);
    
} finally {
  
try {
    
prepStmt.close();
  
} catch (Exception e) {/* Do Nothing 
*/}
  
try {
    
conn.close();
  
} catch (Exception e) {/* Do Nothing 
*/}
 
    
}
 
Every 
time I execute the above method I get the following log 
entry:
 
WARN  
[WrappedConnection] Closing a statement you left open, please do your own 
housekeeping
 
Any idea 
what I’m doing to warrant that warning?  When I step through the code 
with a debugger prepStmt.close() is executed with no exception and when 
conn.close() is executed that warning pops up.  prepStmt is the only 
statement I’m creating with that connection.  Anyone have any 
ideas?
 
Mike


RE: [JBoss-user] Quick JDBC question.

2003-10-10 Thread Mike Youngstrom
I'm not closing the ResultSet?  I thought I wasgranted I'm doing it in a strange 
place.

I changed the code to look like how Rod described and I'm still getting the warning.

Is anyone else experiencing anything like this?  Should I post a bug?

Mike

-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of [EMAIL PROTECTED]
Sent: Friday, October 10, 2003 3:03 AM
To: [EMAIL PROTECTED]
Subject: Re: [JBoss-user] Quick JDBC question.

You haven't closed your resultset...

Harm.




"Mike Youngstrom" <[EMAIL PROTECTED]> 
Sent by: [EMAIL PROTECTED]
10/09/2003 06:37 PM
Please respond to
[EMAIL PROTECTED]


To
<[EMAIL PROTECTED]>
cc

Subject
[JBoss-user] Quick JDBC question.






I’m fairly new to JDBC development and JBoss.  I have the following code 
in a stateless session bean.
 
try {
  boolean exists;
  prepStmt = conn.prepareStatement(USERNAME_EXISTS);
  prepStmt.setString(1, username);
  ResultSet result = prepStmt.executeQuery();
  exists = result.next();
  result.close();
  return exists;
} catch (EJBException e) {
  log.error("Error checking if username exists: ", e);
  throw new EJBException(e);
} finally {
  try {
prepStmt.close();
  } catch (Exception e) {/* Do Nothing */}
  try {
conn.close();
  } catch (Exception e) {/* Do Nothing */}
 
}
 
Every time I execute the above method I get the following log entry:
 
WARN  [WrappedConnection] Closing a statement you left open, please do 
your own housekeeping
 
Any idea what I’m doing to warrant that warning?  When I step through the 
code with a debugger prepStmt.close() is executed with no exception and 
when conn.close() is executed that warning pops up.  prepStmt is the only 
statement I’m creating with that connection.  Anyone have any ideas?
 
Mike

NHYX銲uw+m>xZ zʾMӥ x 'z{B5z Ǿ')rH趟q
z ײ$f뮖)+$X뮶˺~zw۳ q
z  X)



---
This SF.net email is sponsored by: SF.net Giveback Program.
SourceForge.net hosts over 70,000 Open Source Projects.
See the people who have HELPED US provide better services:
Click here: http://sourceforge.net/supporters.php
___
JBoss-user mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/jboss-user


RE: [JBoss-user] Quick JDBC question.

2003-10-10 Thread Mike Youngstrom
Title: Message









Thanks for the tip.  I rewrote the
code like you suggested and I’m still getting the warning.  Any more
ideas?

 

Mike

 

-Original Message-
From:
[EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Rod Macpherson
Sent: Thursday, October 09, 2003
7:12 PM
To:
[EMAIL PROTECTED]
Subject: RE: [JBoss-user] Quick
JDBC question.

 



I would structure this as
follows to make sure the ResultSet is always closed and also so that you do not
get a null pointer if the prepare statement throws:





 







blah blah blah...





 







finally





{





    try 





    {





    if(result != null) result.close();





    if(statement != null) statement.close();





    if(connection != null) connection.close();





    }





    catch(SQLException e) 





    { 





   
logger.error("whaddup?"); 





    }





}





 





 





-Original
Message-
From: Mike Youngstrom
[mailto:[EMAIL PROTECTED] 
Sent: Thursday, October 09, 2003
5:35 PM
To:
[EMAIL PROTECTED]
Subject: RE: [JBoss-user] Quick
JDBC question.

Let me add a little more
information.

 

Version: JBoss 3.2.2 RC3

DBServer Mysql 4.0.15
Windows

JDBCDriver: Connector/J
3.0.8

 

Mike

 

-Original Message-
From:
[EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Mike Youngstrom
Sent: Thursday, October 09, 2003
10:38 AM
To:
[EMAIL PROTECTED]
Subject: [JBoss-user] Quick JDBC
question.

 

I’m
fairly new to JDBC development and JBoss.  I have the following code in a
stateless session bean.

 

   
try
{

 
boolean
exists;

 
prepStmt = conn.prepareStatement(USERNAME_EXISTS);

 
prepStmt.setString(1, username);

 
ResultSet result = prepStmt.executeQuery();

 
exists = result.next();

 
result.close();

 
return
exists;

   
} catch
(EJBException e) {

 
log.error("Error checking if username
exists: ",
e);

 
throw
new
EJBException(e);

   
} finally
{

 
try
{

   
prepStmt.close();

 
} catch
(Exception e) {/* Do Nothing */}

 
try
{

   
conn.close();

 
} catch
(Exception e) {/* Do Nothing */}

 

   
}

 

Every time I execute the above method I get the
following log entry:

 

WARN  [WrappedConnection] Closing a statement
you left open, please do your own housekeeping

 

Any idea what I’m doing to warrant that warning?  When I
step through the code with a debugger prepStmt.close() is executed with no
exception and when conn.close() is executed that warning pops up. 
prepStmt is the only statement I’m creating with that connection. 
Anyone have any ideas?

 

Mike










Re: [JBoss-user] Quick JDBC question.

2003-10-10 Thread harm
You haven't closed your resultset...

Harm.




"Mike Youngstrom" <[EMAIL PROTECTED]> 
Sent by: [EMAIL PROTECTED]
10/09/2003 06:37 PM
Please respond to
[EMAIL PROTECTED]


To
<[EMAIL PROTECTED]>
cc

Subject
[JBoss-user] Quick JDBC question.






I’m fairly new to JDBC development and JBoss.  I have the following code 
in a stateless session bean.
 
try {
  boolean exists;
  prepStmt = conn.prepareStatement(USERNAME_EXISTS);
  prepStmt.setString(1, username);
  ResultSet result = prepStmt.executeQuery();
  exists = result.next();
  result.close();
  return exists;
} catch (EJBException e) {
  log.error("Error checking if username exists: ", e);
  throw new EJBException(e);
} finally {
  try {
prepStmt.close();
  } catch (Exception e) {/* Do Nothing */}
  try {
conn.close();
  } catch (Exception e) {/* Do Nothing */}
 
}
 
Every time I execute the above method I get the following log entry:
 
WARN  [WrappedConnection] Closing a statement you left open, please do 
your own housekeeping
 
Any idea what I’m doing to warrant that warning?  When I step through the 
code with a debugger prepStmt.close() is executed with no exception and 
when conn.close() is executed that warning pops up.  prepStmt is the only 
statement I’m creating with that connection.  Anyone have any ideas?
 
Mike

†+w­zf¢–+,¦‰좷o$…ëFŠ÷›iÉ®ˆ+jd¨º·Šàzw­†‹-²‹ޯ½4ÓC©zt¨º·>º#yËlI筅ê^¢™^Â!j÷‡³Ä
D©®‹âuæ޶׫±êï‰Ǭ
Xœ’«zm§ÿì¢êÜyú+é޷û.¦š+µêì¦I‹,ºǫ™¨¥Šx%ŠËI‹,ºǫ–+-²Ê.­ǟ¢¸ëa¶Úlÿùb²Û,¢êÜyú+é޷ùb²Û?–+-Šwèþ6è²ˬz

RE: [JBoss-user] Quick JDBC question.

2003-10-09 Thread Rod Macpherson
Title: Message



I 
would structure this as follows to make sure the ResultSet is always closed and 
also so that you do not get a null pointer if the prepare statement 
throws:
 

blah 
blah blah...
 
finally
{
    try 
    {
    
if(result != null) 
result.close();
    
if(statement != null) 
statement.close();
    
if(connection != null) 
connection.close();
    }
    catch(SQLException e) 
    { 
    logger.error("whaddup?"); 

    }
}
 
 

  
  -Original Message-From: Mike Youngstrom 
  [mailto:[EMAIL PROTECTED] Sent: Thursday, October 09, 2003 5:35 
  PMTo: [EMAIL PROTECTED]Subject: RE: 
  [JBoss-user] Quick JDBC question.
  
  Let me add a little 
  more information.
   
  Version: JBoss 3.2.2 
  RC3
  DBServer Mysql 4.0.15 
  Windows
  JDBCDriver: 
  Connector/J 3.0.8
   
  Mike
   
  -Original 
  Message-From: 
  [EMAIL PROTECTED] 
  [mailto:[EMAIL PROTECTED] On Behalf Of Mike YoungstromSent: Thursday, October 09, 2003 10:38 
  AMTo: 
  [EMAIL PROTECTED]Subject: [JBoss-user] Quick JDBC 
  question.
   
  I’m 
  fairly new to JDBC development and JBoss.  I have the following code in a 
  stateless session bean.
   
      
  try {
    
  boolean exists;
    
  prepStmt = conn.prepareStatement(USERNAME_EXISTS);
    
  prepStmt.setString(1, username);
    
  ResultSet result = prepStmt.executeQuery();
    
  exists = result.next();
    
  result.close();
    
  return exists;
      
  } catch (EJBException e) {
    
  log.error("Error checking if username exists: 
  ", 
  e);
    
  throw new EJBException(e);
      
  } finally {
    
  try {
      
  prepStmt.close();
    
  } catch (Exception e) {/* Do Nothing */}
    
  try {
      
  conn.close();
    
  } catch (Exception e) {/* Do Nothing */}
   
      
  }
   
  Every 
  time I execute the above method I get the following log 
  entry:
   
  WARN  
  [WrappedConnection] Closing a statement you left open, please do your own 
  housekeeping
   
  Any idea what 
  I’m doing to warrant that warning?  When I step through the code with a 
  debugger prepStmt.close() is executed with no exception and when conn.close() 
  is executed that warning pops up.  prepStmt is the only statement I’m 
  creating with that connection.  Anyone have any ideas?
   
  Mike


RE: [JBoss-user] Quick JDBC question.

2003-10-09 Thread Mike Youngstrom








Let me add a little more information.

 

Version: JBoss 3.2.2 RC3

DBServer Mysql 4.0.15 Windows

JDBCDriver: Connector/J 3.0.8

 

Mike

 

-Original Message-
From:
[EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Mike Youngstrom
Sent: Thursday, October 09, 2003
10:38 AM
To:
[EMAIL PROTECTED]
Subject: [JBoss-user] Quick JDBC
question.

 

I’m fairly new to JDBC development and JBoss.  I
have the following code in a stateless session bean.

 

   
try
{

 
boolean
exists;

 
prepStmt = conn.prepareStatement(USERNAME_EXISTS);

 
prepStmt.setString(1, username);

 
ResultSet result = prepStmt.executeQuery();

 
exists = result.next();

 
result.close();

 
return
exists;

   
} catch
(EJBException e) {

 
log.error("Error checking if username
exists: ",
e);

 
throw
new
EJBException(e);

   
} finally
{

 
try
{

   
prepStmt.close();

 
} catch
(Exception e) {/* Do Nothing */}

 
try
{

   
conn.close();

 
} catch
(Exception e) {/* Do Nothing */}

 

   
}

 

Every time I execute the above method I get the
following log entry:

 

WARN  [WrappedConnection] Closing a statement
you left open, please do your own housekeeping

 

Any idea what I’m doing to warrant that warning?  When I
step through the code with a debugger prepStmt.close() is executed with no
exception and when conn.close() is executed that warning pops up. 
prepStmt is the only statement I’m creating with that connection. 
Anyone have any ideas?

 

Mike








[JBoss-user] Quick JDBC question.

2003-10-09 Thread Mike Youngstrom








I’m
fairly new to JDBC development and JBoss.  I have the following code in a
stateless session bean.

 

    try
{

  boolean
exists;

  prepStmt = conn.prepareStatement(USERNAME_EXISTS);

  prepStmt.setString(1, username);

  ResultSet result = prepStmt.executeQuery();

  exists = result.next();

  result.close();

  return
exists;

    } catch (EJBException e) {

  log.error("Error checking if username
exists: ",
e);

  throw
new
EJBException(e);

    } finally {

  try
{

    prepStmt.close();

  } catch (Exception e) {/* Do Nothing */}

  try
{

    conn.close();

  } catch (Exception e) {/* Do Nothing */}

 

    }

 

Every
time I execute the above method I get the following log entry:

 

WARN 
[WrappedConnection] Closing a statement you left open, please do your own
housekeeping

 

Any idea what I’m
doing to warrant that warning?  When I step through the code with a
debugger prepStmt.close() is executed with no exception and when conn.close() is
executed that warning pops up.  prepStmt is the only statement I’m
creating with that connection.  Anyone have any ideas?

 

Mike