{"id":12228,"date":"2023-11-28T22:47:56","date_gmt":"2023-11-28T14:47:56","guid":{"rendered":"https:\/\/wx.kaifamiao.info\/?p=12228"},"modified":"2023-12-11T15:48:35","modified_gmt":"2023-12-11T07:48:35","slug":"spring-zhongjdbc-api-zhong-cun-zai-na-xie-lei","status":"publish","type":"post","link":"http:\/\/wx.kaifamiao.info\/index.php\/2023\/11\/28\/spring-zhongjdbc-api-zhong-cun-zai-na-xie-lei\/","title":{"rendered":"Spring\u4e2dJDBC API\u4e2d\u5b58\u5728\u54ea\u4e9b\u7c7b\uff1f"},"content":{"rendered":"<p>Spring\u5bf9JDBC\uff08Java Database Connectivity\uff09API\u8fdb\u884c\u4e86\u5c01\u88c5\uff0c\u63d0\u4f9b\u4e86\u4e00\u7cfb\u5217\u7684\u7c7b\u548c\u63a5\u53e3\uff0c\u4ee5\u7b80\u5316\u6570\u636e\u5e93\u8bbf\u95ee\u7684\u8fc7\u7a0b\u3002\u4ee5\u4e0b\u662f\u4e00\u4e9b\u5728Spring JDBC\u4e2d\u5e38\u7528\u7684\u7c7b\u548c\u63a5\u53e3\uff1a<\/p>\n<ol>\n<li>\n<strong>JdbcTemplate\uff1a<\/strong><\/p>\n<ul>\n<li><code>org.springframework.jdbc.core.JdbcTemplate<\/code>\u662fSpring JDBC\u7684\u6838\u5fc3\u7c7b\uff0c\u5b83\u7b80\u5316\u4e86JDBC\u7684\u7528\u6cd5\uff0c\u63d0\u4f9b\u4e86\u4e00\u7cfb\u5217\u7684\u4fbf\u5229\u65b9\u6cd5\uff0c\u5982\u67e5\u8be2\u3001\u66f4\u65b0\u7b49\u3002<\/li>\n<\/ul>\n<\/li>\n<li>\n<strong>DataSource\uff1a<\/strong><\/p>\n<ul>\n<li><code>javax.sql.DataSource<\/code>\u63a5\u53e3\u8868\u793a\u4e00\u4e2a\u6570\u636e\u5e93\u8fde\u63a5\u6c60\u3002Spring\u901a\u8fc7\u8be5\u63a5\u53e3\u63d0\u4f9b\u4e86\u591a\u79cd\u5b9e\u73b0\uff0c\u5982<code>org.springframework.jdbc.datasource.DriverManagerDataSource<\/code>\u3001<code>org.springframework.jdbc.datasource.SimpleDriverDataSource<\/code>\u7b49\u3002<\/li>\n<\/ul>\n<\/li>\n<li>\n<strong>RowMapper\uff1a<\/strong><\/p>\n<ul>\n<li><code>org.springframework.jdbc.core.RowMapper<\/code>\u63a5\u53e3\u7528\u4e8e\u5c06ResultSet\u7684\u6bcf\u4e00\u884c\u6620\u5c04\u4e3a\u76f8\u5e94\u7684Java\u5bf9\u8c61\u3002\u81ea\u5b9a\u4e49\u7684RowMapper\u53ef\u4ee5\u6839\u636e\u9700\u8981\u5b9e\u73b0\u3002<\/li>\n<\/ul>\n<\/li>\n<li>\n<strong>NamedParameterJdbcTemplate\uff1a<\/strong><\/p>\n<ul>\n<li><code>org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate<\/code>\u662f\u5bf9JdbcTemplate\u7684\u6269\u5c55\uff0c\u652f\u6301\u547d\u540d\u53c2\u6570\u7684\u65b9\u5f0f\u8fdb\u884cSQL\u64cd\u4f5c\u3002<\/li>\n<\/ul>\n<\/li>\n<li>\n<strong>SqlParameterSource\uff1a<\/strong><\/p>\n<ul>\n<li><code>org.springframework.jdbc.core.namedparam.SqlParameterSource<\/code>\u63a5\u53e3\u8868\u793a\u53c2\u6570\u6e90\uff0c\u7528\u4e8e\u5c06\u547d\u540d\u53c2\u6570\u6620\u5c04\u5230\u5b9e\u9645\u7684\u503c\u3002<\/li>\n<\/ul>\n<\/li>\n<li>\n<strong>SimpleJdbcInsert\u548cSimpleJdbcCall\uff1a<\/strong><\/p>\n<ul>\n<li><code>org.springframework.jdbc.core.simple.SimpleJdbcInsert<\/code>\u548c<code>org.springframework.jdbc.core.simple.SimpleJdbcCall<\/code>\u662f\u7528\u4e8e\u6267\u884c\u6570\u636e\u5e93\u7684\u63d2\u5165\u548c\u5b58\u50a8\u8fc7\u7a0b\u8c03\u7528\u7684\u7b80\u5316\u5de5\u5177\u7c7b\u3002<\/li>\n<\/ul>\n<\/li>\n<li>\n<strong>KeyHolder\uff1a<\/strong><\/p>\n<ul>\n<li><code>org.springframework.jdbc.support.KeyHolder<\/code>\u63a5\u53e3\u7528\u4e8e\u83b7\u53d6\u7531\u6570\u636e\u5e93\u751f\u6210\u7684\u952e\u503c\uff08\u4f8b\u5982\u81ea\u589e\u4e3b\u952e\uff09\u3002<\/li>\n<\/ul>\n<\/li>\n<li>\n<strong>SqlQuery\u548cSqlUpdate\uff1a<\/strong><\/p>\n<ul>\n<li><code>org.springframework.jdbc.object.SqlQuery<\/code>\u548c<code>org.springframework.jdbc.object.SqlUpdate<\/code>\u662f\u7528\u4e8e\u6267\u884c\u9759\u6001SQL\u67e5\u8be2\u548c\u66f4\u65b0\u7684\u7c7b\u3002<\/li>\n<\/ul>\n<\/li>\n<li>\n<strong>SQLExceptionTranslator\uff1a<\/strong><\/p>\n<ul>\n<li><code>org.springframework.jdbc.support.SQLExceptionTranslator<\/code>\u63a5\u53e3\u7528\u4e8e\u5c06\u6570\u636e\u5e93\u76f8\u5173\u7684\u5f02\u5e38\u8f6c\u6362\u4e3aSpring\u7684DataAccessException\u3002<\/li>\n<\/ul>\n<\/li>\n<\/ol>\n<p>\u8fd9\u4e9b\u7c7b\u548c\u63a5\u53e3\u4f7f\u5f97\u5728Spring\u5e94\u7528\u4e2d\u4f7f\u7528JDBC\u53d8\u5f97\u66f4\u52a0\u7b80\u4fbf\u548c\u7075\u6d3b\uff0c\u540c\u65f6\u9690\u85cf\u4e86\u8bb8\u591a\u4e0e\u6570\u636e\u5e93\u8bbf\u95ee\u76f8\u5173\u7684\u7ec6\u8282\uff0c\u63d0\u9ad8\u4e86\u4ee3\u7801\u7684\u53ef\u7ef4\u62a4\u6027\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Spring\u5bf9JDBC\uff08Java Database Connectivity\uff09API\u8fdb\u884c\u4e86\u5c01\u88c5\uff0c\u63d0\u4f9b\u4e86\u4e00\u7cfb\u5217\u7684 [&hellip;]<\/p>\n","protected":false},"author":9,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[121],"tags":[],"class_list":["post-12228","post","type-post","status-publish","format-standard","hentry","category-spring"],"_links":{"self":[{"href":"http:\/\/wx.kaifamiao.info\/index.php\/wp-json\/wp\/v2\/posts\/12228","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/wx.kaifamiao.info\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/wx.kaifamiao.info\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/wx.kaifamiao.info\/index.php\/wp-json\/wp\/v2\/users\/9"}],"replies":[{"embeddable":true,"href":"http:\/\/wx.kaifamiao.info\/index.php\/wp-json\/wp\/v2\/comments?post=12228"}],"version-history":[{"count":2,"href":"http:\/\/wx.kaifamiao.info\/index.php\/wp-json\/wp\/v2\/posts\/12228\/revisions"}],"predecessor-version":[{"id":47871,"href":"http:\/\/wx.kaifamiao.info\/index.php\/wp-json\/wp\/v2\/posts\/12228\/revisions\/47871"}],"wp:attachment":[{"href":"http:\/\/wx.kaifamiao.info\/index.php\/wp-json\/wp\/v2\/media?parent=12228"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/wx.kaifamiao.info\/index.php\/wp-json\/wp\/v2\/categories?post=12228"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/wx.kaifamiao.info\/index.php\/wp-json\/wp\/v2\/tags?post=12228"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}