{"id":254323,"date":"2022-10-13T09:05:22","date_gmt":"2022-10-13T01:05:22","guid":{"rendered":"https:\/\/lrxjmw.cn\/?p=254323"},"modified":"2022-10-13T09:05:22","modified_gmt":"2022-10-13T01:05:22","slug":"linux-3steps-jdbc","status":"publish","type":"post","link":"https:\/\/lrxjmw.cn\/linux-3steps-jdbc.html","title":{"rendered":"\u5728 Linux \u4e0a\u4e09\u6b65\u5b89\u88c5 JDBC"},"content":{"rendered":"\n\n\n
\u5bfc\u8bfb<\/td>\n\u5b89\u88c5 Java\uff0c\u4f7f\u7528 Maven \u5b89\u88c5 JDBC\uff0c\u5e76\u5b89\u88c5\u6570\u636e\u5e93\u3002\u7136\u540e\uff0c\u4f60\u5c31\u53ef\u4ee5\u5728 Java \u4ee3\u7801\u4e2d\u4e0e\u6570\u636e\u5e93\u8fdb\u884c\u4ea4\u4e92\u4e86\u3002<\/strong><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n

\u5f53\u4f60\u7f16\u5199\u4e00\u4e2a\u5e94\u7528\u65f6\uff0c\u9700\u8981\u6570\u636e\u5b58\u50a8\u662f\u5f88\u5e38\u89c1\u7684\u3002\u6709\u65f6\u4f60\u8981\u5b58\u50a8\u4f60\u7684\u5e94\u7528\u9700\u8981\u7684\u7d20\u6750\u6570\u636e\uff0c\u5176\u4ed6\u65f6\u5019\u4f60\u8981\u5b58\u50a8\u7528\u6237\u6570\u636e\uff0c\u5305\u62ec\u504f\u597d\u548c\u4fdd\u5b58\u7684\u6570\u636e\u3002\u5b58\u50a8\u6570\u636e\u7684\u4e00\u79cd\u65b9\u5f0f\u662f\u5728\u6570\u636e\u5e93\u4e2d\uff0c\u4e3a\u4e86\u5728\u4f60\u7684\u4ee3\u7801\u548c\u6570\u636e\u5e93\u4e4b\u95f4\u8fdb\u884c\u901a\u4fe1\uff0c\u4f60\u9700\u8981\u4e3a\u4f60\u7684\u8bed\u8a00\u63d0\u4f9b\u4e00\u4e2a\u6570\u636e\u5e93\u7ed1\u5b9a\u6216\u8fde\u63a5\u5668\u3002\u5bf9\u4e8e Java \u6765\u8bf4\uff0c\u4e00\u4e2a\u5e38\u89c1\u7684\u6570\u636e\u5e93\u8fde\u63a5\u5668\u662f JDBC\uff08Java \u6570\u636e\u5e93\u8fde\u63a5Java database connectivity\uff09\u3002<\/p>\n

1\u3001\u5b89\u88c5 Java<\/strong><\/div>\n

\u5f53\u7136\uff0c\u8981\u4f7f\u7528 Java \u8fdb\u884c\u5f00\u53d1\uff0c\u4f60\u8fd8\u5fc5\u987b\u5b89\u88c5 Java\u3002\u5bf9\u4e8e Linux\u3001macOS \u548c WSL \u6216 Cygwin\uff0c\u6211\u63a8\u8350 SDKman\u3002\u5bf9\u4e8e Windows\uff0c\u4f60\u53ef\u4ee5\u4ece developers.redhat.com \u4e0b\u8f7d OpenJDK\u3002<\/p>\n

2\u3001\u4f7f\u7528 Maven \u5b89\u88c5 JDBC<\/strong><\/div>\n

JDBC \u662f\u4e00\u79cd API\uff0c\u901a\u8fc7\u8bed\u53e5 import java.sql.* \u5bfc\u5165\u5230\u4f60\u7684\u4ee3\u7801\u4e2d\uff0c\u4f46\u8981\u4f7f\u5176\u6709\u7528\uff0c\u4f60\u5fc5\u987b\u5b89\u88c5\u6570\u636e\u5e93\u9a71\u52a8\u548c\u6570\u636e\u5e93\u4ee5\u4e0e\u4e4b\u4ea4\u4e92\u3002\u4f60\u4f7f\u7528\u7684\u6570\u636e\u5e93\u9a71\u52a8\u548c\u8981\u901a\u4fe1\u7684\u6570\u636e\u5e93\u5fc5\u987b\u5339\u914d\uff1a\u8981\u4e0e MySQL \u4ea4\u4e92\uff0c\u4f60\u9700\u8981 MySQL \u9a71\u52a8\uff0c\u8981\u4e0e SQLite3 \u4ea4\u4e92\uff0c\u4f60\u5fc5\u987b\u5177\u6709 SQLite3 \u9a71\u52a8\u7b49\u7b49\u3002<\/p>\n

\u5728\u672c\u6587\u4e2d\uff0c\u6211\u4f7f\u7528 PostgreSQL\uff0c\u4f46\u6240\u6709\u4e3b\u6d41\u6570\u636e\u5e93\uff0c\u5305\u62ec MariaDB \u548c SQLite3\uff0c\u90fd\u6709 JDBC \u9a71\u52a8\u7a0b\u5e8f\u3002<\/p>\n

\u4f60\u53ef\u4ee5\u4ece jdbc.postgresql.org \u4e0b\u8f7d JDBC for PostgreSQL\u3002\u6211\u4f7f\u7528 Maven \u6765\u7ba1\u7406 Java \u4f9d\u8d56\u9879\uff0c\u56e0\u6b64\u6211\u5c06\u5b83\u5305\u542b\u5728 pom.xml \u4e2d\uff08\u8c03\u6574 Maven Central \u4e0a\u7684\u5f53\u524d\u7248\u672c\u53f7\uff09\uff1a<\/p>\n

\r\n<dependency>\r\n    <groupId>org.postgresql<\/groupId>\r\n    <artifactId>postgresql<\/artifactId>\r\n    <version>42.5.0<\/version>\r\n<\/dependency>\r\n<\/pre>\n
3\u3001\u5b89\u88c5\u6570\u636e\u5e93<\/strong><\/div>\n

\u4f60\u5fc5\u987b\u5b89\u88c5\u8981\u901a\u8fc7 JDBC \u8fde\u63a5\u7684\u6570\u636e\u5e93\u3002\u6709\u51e0\u4e2a\u975e\u5e38\u597d\u7684\u5f00\u6e90\u6570\u636e\u5e93\uff0c\u4f46\u662f\u6211\u53ea\u80fd\u4e3a\u8fd9\u7bc7\u6587\u7ae0\u9009\u62e9\u4e00\u4e2a\uff0c\u6240\u4ee5\u6211\u9009\u62e9\u4e86 PostgreSQL\u3002<\/p>\n

\u8981\u5728 Linux \u4e0a\u5b89\u88c5 PostgreSQL\uff0c\u8bf7\u4f7f\u7528\u4f60\u7684\u8f6f\u4ef6\u4ed3\u5e93\u3002\u5728 Fedora\u3001CentOS\u3001Mageia \u548c\u7c7b\u4f3c\u8bbe\u5907\u4e0a\uff1a<\/p>\n

\r\n$ sudo dnf install postgresql postgresql-server\r\n<\/pre>\n

\u5728 Debian\u3001Linux Mint\u3001Elementary \u548c\u7c7b\u4f3c\u5e73\u53f0\u4e0a\uff1a<\/p>\n

\r\n$ sudo apt install postgresql postgresql-contrib\r\n<\/pre>\n
\u6570\u636e\u5e93\u8fde\u63a5<\/strong><\/div>\n

\u5982\u679c\u4f60\u4e0d\u4f7f\u7528 PostgreSQL\uff0c\u540c\u6837\u7684\u4e00\u822c\u8fc7\u7a0b\u4e5f\u9002\u7528\uff1a<\/p>\n

    \n
  1. \u5b89\u88c5 Java\u3002<\/li>\n
  2. \u4e3a\u4f60\u9009\u62e9\u7684\u6570\u636e\u5e93\u627e\u5230 JDBC \u9a71\u52a8\uff0c\u5e76\u5c06\u5176\u5305\u542b\u5728\u4f60\u7684 pom.xml \u6587\u4ef6\u4e2d\u3002<\/li>\n
  3. \u5728\u4f60\u7684\u5f00\u53d1\u7cfb\u7edf\u4e0a\u5b89\u88c5\u6570\u636e\u5e93\uff08\u670d\u52a1\u5668\u548c\u5ba2\u6237\u7aef\uff09\u3002<\/li>\n<\/ol>\n

    \u4e09\u4e2a\u6b65\u9aa4\uff0c\u4f60\u5c31\u53ef\u4ee5\u5f00\u59cb\u7f16\u5199\u4ee3\u7801\u4e86\u3002<\/p>\n

    via: https:\/\/opensource.com\/article\/22\/9\/install-jdbc-linux<\/p>\n

    \u4f5c\u8005\uff1aSeth Kenlon \u9009\u9898\uff1alkxed \u8bd1\u8005\uff1ageekpi \u6821\u5bf9\uff1awxy<\/p>\n

    \u672c\u6587\u7531 LCTT \u539f\u521b\u7f16\u8bd1\uff0cLinux\u4e2d\u56fd \u8363\u8a89\u63a8\u51fa<\/p>\n","protected":false},"excerpt":{"rendered":"

    \u5f53\u4f60\u7f16\u5199\u4e00\u4e2a\u5e94\u7528\u65f6\uff0c\u9700\u8981\u6570\u636e\u5b58\u50a8\u662f\u5f88\u5e38\u89c1\u7684\u3002\u6709\u65f6\u4f60\u8981\u5b58\u50a8\u4f60\u7684\u5e94\u7528\u9700\u8981\u7684\u7d20\u6750\u6570\u636e\uff0c\u5176\u4ed6\u65f6\u5019\u4f60\u8981\u5b58\u50a8\u7528\u6237\u6570\u636e\uff0c\u5305\u62ec […]<\/p>\n","protected":false},"author":317,"featured_media":231830,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[55],"tags":[],"class_list":["post-254323","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-thread"],"acf":[],"_links":{"self":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/254323","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/users\/317"}],"replies":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/comments?post=254323"}],"version-history":[{"count":5,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/254323\/revisions"}],"predecessor-version":[{"id":254328,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/254323\/revisions\/254328"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/media\/231830"}],"wp:attachment":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/media?parent=254323"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/categories?post=254323"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/tags?post=254323"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}