##### General

- Home
- Downloads
- Javadocs
- Mailing Lists
- Bug Tracker
- SourceForge Project
- GitHub Project

##### Running

- Ant Task Usage
- Command-Line
- Run as a Test
- Other Tools/Frameworks

##### Using

- Creating a RuleSet
- Creating a Rule
- Configuring Rules
- Starter RuleSet (All)

##### Report Types

- HTML Report
- XML Report
- Text and IDE Reports

##### Sample Reports

- Sample HTML Report
- Sample XML Report

##### Rules

- Rule Index
- Basic Rules
- Braces Rules
- Concurrency Rules
- Convention Rules
- Design Rules
- DRY Rules
- Enhanced Rules
- Exceptions Rules
- Formatting Rules
- Generic Rules
- Grails Rules
- Groovyism Rules
- Imports Rules
- JDBC Rules
- JUnit Rules
- Logging Rules
- Naming Rules
- Size/Complexity Rules
- Security Rules
- Serialization Rules
- Unnecessary Rules
- Unused Rules

##### Developing

- Developer Guide

##### Project Documentation

- Project Information
- Project Reports

## JDBC Rules ("rulesets/jdbc.xml")

### DirectConnectionManagement Rule

New in CodeNarc 0.14

The J2EE standard requires that applications use the container's resource management facilities to obtain connections to resources. 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.

For more information see: https://www.fortify.com/vulncat/en/vulncat/java/j2ee_badpractices_getconnection.html

Example of violations:

        DriverManager.getConnection()
        java.sql.DriverManager.getConnection()

### JdbcConnectionReference Rule

New in CodeNarc 0.15

Checks for direct use of `java.sql.Connection`, which is discouraged and almost never necessary in application code.

For a more Groovy alternative, see http://groovy.codehaus.org/Database+features for information on the Groovy Sql abstraction layer for JDBC/SQL.

Note: If a violation is triggered from an import statement, then you may get multiple violations per import if there are multiple classes in the source file. In that case, the imports are processed once per class.

### JdbcResultSetReference Rule

New in CodeNarc 0.15

Checks for direct use of `java.sql.ResultSet`, which is not necessary if using the Groovy Sql facility or an ORM framework such as Hibernate.

See http://groovy.codehaus.org/Database+features for information on the Groovy Sql abstraction layer for JDBC/SQL.

Note: If a violation is triggered from an import statement, then you may get multiple violations per import if there are multiple classes in the source file. In that case, the imports are processed once per class.

### JdbcStatementReference Rule

New in CodeNarc 0.15

Checks for direct use of `java.sql.Statement`, `java.sql.PreparedStatement`, or `java.sql.CallableStatement`, which is not necessary if using the Groovy Sql facility or an ORM framework such as Hibernate.

See http://groovy.codehaus.org/Database+features for information on the Groovy Sql abstraction layer for JDBC/SQL.

Note: If a violation is triggered from an import statement, then you may get multiple violations per import if there are multiple classes in the source file. In that case, the imports are processed once per class.