Hi all , i am using RedHat6.1 ,jdk1.3,postgresql7.0.1 and jboss2.1.

  I need some advice regarding the code below which in stateless session
bean :
  My question is that if the connection below created are pooled ???
Thanks wt.

    
  // code 

  public int executeSQLStatement(String sqlstr){

   int key = 0;
   Connection conn = null;
   PreparedStatement ps = null;
   ResultSet rs = null;

   try{

    conn = this.getConnection() ;
    ps = conn.prepareStatement(sqlstr);
    rs = ps.executeQuery();

    if(rs.next()){
      key = rs.getInt("nextval");
     }
   }catch(Exception ce){
    ce.printStackTrace();
    }
   finally{
     try{
      if(rs != null) rs.close();
      if(ps != null) ps.close();
      if(conn != null) conn.close();
     }catch(SQLException se){
      se.printStackTrace();
     }
    }

    return key;
  }

  private Connection getConnection() throws SQLException{
   DataSource ds = null;
    try{
      Context ctx = new InitialContext();
      ds = (DataSource)ctx.lookup("java:comp/env/jdbc/PostgresDS");
    }
    catch(NamingException ne){
     ne.printStackTrace();
    }
   return ds.getConnection();
  }

_______________________________________________
JBoss-user mailing list
[EMAIL PROTECTED]
http://lists.sourceforge.net/lists/listinfo/jboss-user

Reply via email to