What does your getConnection() method do? If it does a JNDI lookup (just
like a BMP bean would) you're fine. You really shouldn't use the
DriverManager (traditional JDBC) stuff, though. See Peter's post on one
reason why.
Ricky wrote:
>
> Hi all , i am using jBoss-FINAL_2.0 container .
> My question is that can i do open Connection in the CMP bean in
> ejbCreate() .
> Any wrong with that ? Is violated the EJB specification ??
>
> Please commment. Below is the CMP bean code:
>
>
> public UsersPK ejbCreate(String username,String password,boolean
> isadmin) throws CreateException {
>
> Connection conn = null;
> PreparedStatement ps = null;
> ResultSet rs = null;
>
> try{
> conn = this.getConnection();
> ps = conn.prepareStatement("Select NEXTVAL('userproject_seq') from
> test_seq");
> rs = ps.executeQuery();
>
> if(rs.next()){
> this.userid = rs.getInt(1);
> }
> }
> catch(SQLException se){}
> finally{
> try{
> if(conn != null) conn.close();
> if(rs != null ) rs.close();
> if(ps != null ) ps.close();
> }
> catch(SQLException se){}
> }
>
> this.username = username;
> this.password = password;
> this.isadmin = isadmin;
>
> return null;
>
> }
>
>
> --
> --------------------------------------------------------------
> To subscribe: [EMAIL PROTECTED]
> To unsubscribe: [EMAIL PROTECTED]
--
--------------------------------------------------------------
To subscribe: [EMAIL PROTECTED]
To unsubscribe: [EMAIL PROTECTED]