{"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":"
\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 |