For performance reasons, use the recommended getXXX method when retrieving values, and use the recommended setXXX method when setting values for parameters. JDBC is permissive. It lets you use java.sql.ResultSet.getFloat to retrieve an int, java.sql.ResultSet.getObject to retrieve any type, and so on. (java.sql.ResultSet and java.sql.CallableStatement provide getXXX methods, and java .sql.PreparedStatement and java.sql.CallableStatement provide setXXX methods.) This permissiveness is convenient but expensive in terms of performance. The following table shows the recommended getXXX methods for given java.sql (JDBC) types, and their corresponding SQL types.
[url]http://db.apache.org/derby/docs/10.8/tuning/ctunperf98197.html[/url]
[url]http://db.apache.org/derby/docs/10.8/tuning/ctunperf98197.html[/url]
本文介绍了使用JDBC时为了提高性能推荐采用的最佳实践。建议使用特定类型的getXXX和setXXX方法来代替通用方法,例如使用getFloat替代getInt等。虽然JDBC允许使用通用方法,但这会带来额外的性能开销。

1322

被折叠的 条评论
为什么被折叠?



