輔助編寫高效和正確的JDBC API代碼:JDBC lint
JDBC lint能夠幫助Java程序員編寫正確和高效的代碼,當使用JDBC API時。JDBC lint需要Java 6并且沒有其它運行期依賴。
示例
用戶可以使用 JDBC lint 來封裝 Connection 或 DataSource 對象:
import com.maginatics.jdbclint.Configuration;
import com.maginatics.jdbclint.Configuration.Check;
import com.maginatics.jdbclint.ConnectionProxy;
...
Configuration config = new Configuration(EnumSet.allOf(Check.class),
Arrays.<Configuration.Action>asList(
Configuration.PRINT_STACK_TRACE_ACTION,
Configuration.THROW_SQL_EXCEPTION_ACTION));
Connection connection = DriverManager.getConnection(...);
connection = ConnectionProxy.newInstance(connection, config);
connection.close();
connection.close(); // triggers error, runs Actions
本文由用戶 jopen 自行上傳分享,僅供網友學習交流。所有權歸原作者,若您的權利被侵害,請聯系管理員。
轉載本站原創文章,請注明出處,并保留原始鏈接、圖片水印。
本站是一個以用戶分享為主的開源技術平臺,歡迎各類分享!