This site is the archived OWASP Foundation Wiki and is no longer accepting Account Requests.
To view the new OWASP Foundation website, please visit https://owasp.org

J2EE Bad Practices: getConnection()

From OWASP
Revision as of 20:16, 7 April 2009 by KirstenS (talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

Template:CandidateForDeletion

#REDIRECT Failure to follow guideline/specification


Last revision (mm/dd/yy): 04/7/2009

Description

The J2EE standard forbids the direct management of connections.

The J2EE standard requires that applications use the container's resource management facilities to obtain connections to resources.


Risk Factors

TBD

Examples

For example, a J2EE application should obtain a database connection as follows:

 ctx = new InitialContext();
 datasource = (DataSource)ctx.lookup(DB_DATASRC_REF);
 conn = datasource.getConnection();

and should avoid obtaining a connection in this way:

 conn = DriverManager.getConnection(CONNECT_STRING);

Every major web application container provides pooled database connection management as part of its resource management framework. Duplicating this functionality in an application is difficult and error prone, which is part of the reason it is forbidden under the J2EE standard.


Related Attacks


Related Vulnerabilities


Related Controls


Related Technical Impacts


References

TBD