{"id":325545,"date":"2021-06-26T15:00:35","date_gmt":"2021-06-26T15:00:35","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=325545"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=325545","title":{"rendered":"\u041f\u0440\u0438\u043c\u0435\u043d\u0435\u043d\u0438\u0435 JDBC \u0432 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0435 ETL"},"content":{"rendered":"\n<div class=\"post__text post__text_v2\" id=\"post-content-body\">\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/c00\/fb7\/bd6\/c00fb7bd6d46d4f6811a4e280af9fc00.png\" width=\"1200\" height=\"720\"><figcaption><\/figcaption><\/figure>\n<p>\u0412&nbsp;<a href=\"https:\/\/habr.com\/ru\/post\/564648\/\" rel=\"noopener noreferrer nofollow\">\u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0435\u0439 \u0441\u0442\u0430\u0442\u044c\u0435<\/a>&nbsp;\u043c\u044b \u0443\u043f\u043e\u043c\u0438\u043d\u0430\u043b\u0438 \u043e Java + JDBC \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u0430\u043b\u044c\u0442\u0435\u0440\u043d\u0430\u0442\u0438\u0432\u044b Python + ODBC. \u0412 \u044d\u0442\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u043f\u0440\u0438\u0432\u0435\u0434\u0451\u043c \u0443\u0441\u043b\u043e\u0432\u043d\u0443\u044e \u0441\u0438\u0442\u0443\u0430\u0446\u0438\u044e, \u043f\u0440\u0438\u0431\u043b\u0438\u0436\u0435\u043d\u043d\u0443\u044e \u043a \u0442\u043e\u0439, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u043f\u043e\u0431\u0443\u0434\u0438\u043b\u0430 \u043d\u0430\u0441 \u0441\u043c\u0435\u043d\u0438\u0442\u044c \u044f\u0437\u044b\u043a \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f.<\/p>\n<p>\u0411\u044b\u043b\u0430 \u043f\u043e\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0430 \u0437\u0430\u0434\u0430\u0447\u0430 \u043f\u043e \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0435 \u0431\u043e\u043b\u0435\u0435 25 \u043c\u043b\u043d. \u0441\u0442\u0440\u043e\u043a \u043f\u043e\u0441\u0440\u0435\u0434\u0441\u0442\u0432\u043e\u043c \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0430 ETL: \u043d\u0430 \u043e\u0441\u043d\u043e\u0432\u0435 \u0438\u043c\u0435\u044e\u0449\u0438\u0445\u0441\u044f \u0434\u0430\u043d\u043d\u044b\u0445 \u0440\u0430\u0441c\u0447\u0438\u0442\u0430\u0442\u044c \u0434\u0432\u0430 \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0445 \u0441\u0442\u043e\u043b\u0431\u0446\u0430 \u0438 \u0432\u0435\u0440\u043d\u0443\u0442\u044c \u0438\u0445 \u0432 \u0431\u0430\u0437\u0443. Python \u043f\u0440\u0435\u043a\u0440\u0430\u0441\u043d\u043e \u0441\u043f\u0440\u0430\u0432\u043b\u044f\u043b\u0441\u044f \u0441 \u043f\u043e\u0434\u043e\u0431\u043d\u044b\u043c\u0438 \u0437\u0430\u0434\u0430\u0447\u0430\u043c\u0438, \u043d\u043e \u0432 \u0434\u0430\u043d\u043d\u043e\u0439 \u0441\u0438\u0442\u0443\u0430\u0446\u0438\u0438 \u0441\u043a\u043e\u0440\u043e\u0441\u0442\u044c \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u044f \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0430 \u0431\u044b\u043b\u0430 \u043d\u0435 \u0441\u0430\u043c\u043e\u0439 \u043e\u043f\u0442\u0438\u043c\u0430\u043b\u044c\u043d\u043e\u0439: \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0430 \u0434\u043b\u0438\u043b\u0430\u0441\u044c \u0431\u043e\u043b\u0435\u0435 \u0441\u0443\u0442\u043e\u043a.<\/p>\n<p>\u0422\u0430\u043a \u043a\u0430\u043a \u043f\u0440\u043e\u0446\u0435\u0434\u0443\u0440\u0443 \u043f\u0440\u0435\u0434\u043f\u043e\u043b\u0430\u0433\u0430\u043b\u043e\u0441\u044c \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0442\u044c \u043c\u043d\u043e\u0433\u043e\u043a\u0440\u0430\u0442\u043d\u043e, \u0442\u043e \u0431\u044b\u043b\u043e \u0440\u0435\u0448\u0435\u043d\u043e \u043d\u0430\u0439\u0442\u0438 \u0431\u043e\u043b\u0435\u0435 \u0431\u044b\u0441\u0442\u0440\u044b\u0439 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442. \u041f\u043e\u0438\u0441\u043a \u0430\u043b\u044c\u0442\u0435\u0440\u043d\u0430\u0442\u0438\u0432\u043d\u044b\u0445 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a \u0434\u043b\u044f Python \u043d\u0438 \u043a \u0447\u0435\u043c\u0443 \u043d\u0435 \u043f\u0440\u0438\u0432\u0451\u043b. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u0431\u044b\u043b\u043e \u0440\u0435\u0448\u0435\u043d\u043e \u043f\u0440\u0438\u043c\u0435\u043d\u0438\u0442\u044c \u0442\u044f\u0436\u0451\u043b\u0443\u044e \u0430\u0440\u0442\u0438\u043b\u043b\u0435\u0440\u0438\u044e \u2014 Java, \u0442\u0430\u043a \u043a\u0430\u043a Java \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u0441 \u0411\u0414 \u0431\u044b\u0441\u0442\u0440\u0435\u0435, \u0447\u0435\u043c Python \u0447\u0438\u0441\u0442\u043e \u0442\u0435\u0445\u043d\u0438\u0447\u0435\u0441\u043a\u0438. \u0418 \u0447\u0435\u043c \u0431\u043e\u043b\u044c\u0448\u0435 \u043e\u0431\u044a\u0451\u043c \u0434\u0430\u043d\u043d\u044b\u0445, \u0442\u0435\u043c \u0437\u0430\u043c\u0435\u0442\u043d\u0435\u0435 \u0440\u0435\u0430\u043b\u0438\u0437\u0443\u0435\u0442\u0441\u044f \u044d\u0442\u043e \u043f\u0440\u0435\u0438\u043c\u0443\u0449\u0435\u0441\u0442\u0432\u043e.<\/p>\n<p>\u041d\u0430 \u043f\u0435\u0440\u0432\u043e\u043c \u044d\u0442\u0430\u043f\u0435 \u0440\u0430\u0437\u043e\u0432\u044c\u0451\u043c \u043a\u043b\u0430\u0441\u0441 DBC \u0438\u0437 \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0435\u0439 \u0441\u0442\u0430\u0442\u044c\u0438, \u0434\u043e\u0431\u0430\u0432\u0438\u0432:<\/p>\n<ol>\n<li>\n<p>\u043c\u0435\u0442\u043e\u0434 execQuerySelect \u0434\u043b\u044f \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f select-\u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432 \u0432 \u0440\u0430\u0437\u043d\u044b\u0445 \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u0430\u0445 (\u0441 TOP, where \u0438 \u0442.\u0434.)<\/p>\n<\/li>\n<li>\n<p>\u043c\u0435\u0442\u043e\u0434 execQueryInsert \u0434\u043b\u044f \u0432\u0441\u0442\u0430\u0432\u043a\u0438 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0430 \u0432 \u0411\u0414<\/p>\n<\/li>\n<li>\n<p>\u0432\u0441\u043f\u043e\u043c\u043e\u0433\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u043c\u0435\u0442\u043e\u0434\u0430 buildInsertColumns \u0438 buildInsertValues \u0434\u043b\u044f \u0444\u043e\u0440\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u043a\u043e\u043b\u043e\u043d\u043e\u043a \u0438 \u0441\u0442\u0440\u043e\u043a \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0435\u043d\u043d\u043e.<\/p>\n<\/li>\n<\/ol>\n<p>\u0412 \u0438\u0442\u043e\u0433\u0435 \u043a\u043b\u0430\u0441\u0441 DBC \u043f\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0441\u044f \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u043a\u043e\u0434\u043e\u043c:<\/p>\n<pre><code>\/**      * \u0412\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435 select \u0437\u0430\u043f\u0440\u043e\u0441\u0430 \u043a \u0411\u0414      *      * @param select \u041d\u0430\u0437\u0432\u0430\u043d\u0438\u044f \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b\u0445 \u043a\u043e\u043b\u043e\u043d\u043e\u043a (* - \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0432\u0441\u0435)      * @param from   \u0422\u0430\u0431\u043b\u0438\u0446\u0430 \u0438\u0437 \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u043d\u0435\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0434\u0430\u043d\u043d\u044b\u0435      * @return ResultSet \u0441 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0430\u043c\u0438 \u0440\u0430\u0431\u043e\u0442\u044b \u0437\u0430\u043f\u0440\u043e\u0441\u0430      *\/     public ResultSet execQuerySelect(String select, String from) {         if (!readyToWork) {             System.err.println(\"DBC not ready to work! Abort:execQuerySelected\");             return null;         }          String query = \"SELECT \" + select + \" FROM \" + from;          return execQuery(query);     }      \/**      * \u0412\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435 select \u0437\u0430\u043f\u0440\u043e\u0441\u0430 \u043a \u0411\u0414      *      * @param select \u041d\u0430\u0437\u0432\u0430\u043d\u0438\u044f \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b\u0445 \u043a\u043e\u043b\u043e\u043d\u043e\u043a (* - \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0432\u0441\u0435)      * @param from   \u0422\u0430\u0431\u043b\u0438\u0446\u0430 \u0438\u0437 \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u043d\u0435\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0434\u0430\u043d\u043d\u044b\u0435      * @param top    \u041a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \"\u0432\u0435\u0440\u0445\u043d\u0438\u0445\" \u0441\u0442\u0440\u043e\u043a \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c\u044b\u0445 \u0438\u0437 \u0431\u0430\u0437\u044b      * @return ResultSet \u0441 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0430\u043c\u0438 \u0440\u0430\u0431\u043e\u0442\u044b \u0437\u0430\u043f\u0440\u043e\u0441\u0430      *\/     public ResultSet execQuerySelect(String select, String from, Integer top) {         if (!readyToWork) {             System.err.println(\"DBC not ready to work! Abort:execQuerySelected\");             return null;         }          String query = \"SELECT TOP(\" + top + \") \" + select + \" FROM \" + from;          return execQuery(query);     }      \/**      * \u0412\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435 select \u0437\u0430\u043f\u0440\u043e\u0441\u0430 \u043a \u0411\u0414      *      * @param select \u041d\u0430\u0437\u0432\u0430\u043d\u0438\u044f \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b\u0445 \u043a\u043e\u043b\u043e\u043d\u043e\u043a (* - \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0432\u0441\u0435)      * @param from   \u0422\u0430\u0431\u043b\u0438\u0446\u0430 \u0438\u0437 \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u043d\u0435\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0434\u0430\u043d\u043d\u044b\u0435      * @param where  \u0423\u0441\u043b\u043e\u0432\u0438\u0435 \u0432\u044b\u0431\u043e\u0440\u043a\u0438 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439 \u0438\u0437 \u0442\u0430\u0431\u043b\u0438\u0446\u044b      * @return ResultSet \u0441 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0430\u043c\u0438 \u0440\u0430\u0431\u043e\u0442\u044b \u0437\u0430\u043f\u0440\u043e\u0441\u0430      *\/     public ResultSet execQuerySelect(String select, String from, String where) {         if (!readyToWork) {             System.err.println(\"DBC not ready to work! Abort:execQuerySelected\");             return null;         }          String query = \"SELECT \" + select + \" FROM \" + from + \" WHERE \" + where;          return execQuery(query);     }      \/**      * \u0412\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435 select \u0437\u0430\u043f\u0440\u043e\u0441\u0430 \u043a \u0411\u0414      *      * @param select \u041d\u0430\u0437\u0432\u0430\u043d\u0438\u044f \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b\u0445 \u043a\u043e\u043b\u043e\u043d\u043e\u043a (* - \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0432\u0441\u0435)      * @param from   \u0422\u0430\u0431\u043b\u0438\u0446\u0430 \u0438\u0437 \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u043d\u0435\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0434\u0430\u043d\u043d\u044b\u0435      * @param where  \u0423\u0441\u043b\u043e\u0432\u0438\u0435 \u0432\u044b\u0431\u043e\u0440\u043a\u0438 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439 \u0438\u0437 \u0442\u0430\u0431\u043b\u0438\u0446\u044b      * @param top    \u041a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \"\u0432\u0435\u0440\u0445\u043d\u0438\u0445\" \u0441\u0442\u0440\u043e\u043a \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c\u044b\u0445 \u0438\u0437 \u0431\u0430\u0437\u044b      * @return ResultSet \u0441 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0430\u043c\u0438 \u0440\u0430\u0431\u043e\u0442\u044b \u0437\u0430\u043f\u0440\u043e\u0441\u0430      *\/     public ResultSet execQuerySelect(String select, String from, String where, Integer top) {         if (!readyToWork) {             System.err.println(\"DBC not ready to work! Abort:execQuerySelected\");             return null;         }          String query = \"SELECT TOP(\" + top + \") \" + select + \" FROM \" + from + \" WHERE \" + where;          return execQuery(query);     }      \/**      * \u0412\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435 insert \u0437\u0430\u043f\u0440\u043e\u0441\u0430 \u043a \u0411\u0414      *      * @param table \u0418\u043c\u044f \u0442\u0430\u0431\u043b\u0438\u0446\u044b \u0434\u043b\u044f \u0432\u0441\u0442\u0430\u0432\u043a\u0438      * @param columns \u041c\u0430\u0441\u0441\u0438\u0432 \u043a\u043e\u043b\u043e\u043d\u043e\u043a \u0434\u043b\u044f \u0432\u0441\u0442\u0430\u0432\u043a\u0438      * @param data \u0412\u0435\u043a\u0442\u043e\u0440 \u0441\u043b\u043e\u0432\u0430\u0440\u0435\u0439 \u0441\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f\u043c\u0438 \u0434\u043b\u044f \u0432\u0441\u0442\u0430\u0432\u043a\u0438      * @return \u0424\u043b\u0430\u0433 \u0443\u0441\u043f\u0435\u0448\u043d\u043e\u0441\u0442\u0438 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u0437\u0430\u043f\u0440\u043e\u0441\u0430      *\/     public boolean execQueryInsert(String table, String[] columns, Vector&lt;HashMap&lt;String, String&gt;&gt; data) {         if (!readyToWork) {             System.err.println(\"DBC not ready to work! Abort:execQuerySelected\");             return false;         }          String query = \"INSERT INTO \" + table + \" \" + buildInsertColumns(columns) + \" VALUES \";          for (int i = 0; i &lt; data.size() - 1; i++) {             query = query.concat(buildInsertValues(columns, data.get(i), false));         }          query = query.concat(buildInsertValues(columns, data.get(data.size() - 1), true));          execQuery(query);         return true;     } \t \t    \/**      * \u0424\u043e\u0440\u043c\u0438\u0440\u0443\u0435\u0442 \u0441\u0442\u0440\u043e\u043a\u0443 \u0441 \u043f\u0435\u0440\u0435\u0447\u043d\u0435\u043c \u043a\u043e\u043b\u043e\u043d\u043e\u043a \u0434\u043b\u044f \u0437\u0430\u043f\u0440\u043e\u0441\u0430 insert      *      * @param columns \u041c\u0430\u0441\u0441\u0438\u0432 \u043a\u043e\u043b\u043e\u043d\u043e\u043a      * @return \u0421\u0442\u0440\u043e\u043a\u0443 \u0441 \u043f\u0435\u0440\u0435\u0447\u043d\u0435\u043c \u043a\u043e\u043b\u043e\u043d\u043e\u043a \u0434\u043b\u044f \u0437\u0430\u043f\u0440\u043e\u0441\u0430 insert      *\/     private String buildInsertColumns (String[] columns) {          String r = \"(\";          for (int i = 0; i &lt; columns.length - 1; i++) {             r = r.concat(\"[\" + columns[i] + \"], \");         }          r = r.concat(\"[\" + columns[columns.length-1] + \"])\");          return r;     }      \/**      * \u0424\u043e\u0440\u043c\u0438\u0440\u0443\u0435\u0442 \u0441\u0442\u0440\u043e\u043a\u0443 \u0441 \u043f\u0435\u0440\u0435\u0447\u043d\u0435\u043c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439 \u0434\u043b\u044f \u0437\u0430\u043f\u0440\u043e\u0441\u0430 insert      *      * @param columns \u041c\u0430\u0441\u0441\u0438\u0432 \u043a\u043e\u043b\u043e\u043d\u043e\u043a      * @param data \u0421\u043b\u043e\u0432\u0430\u0440\u044c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439 \u0434\u043b\u044f \u0432\u0441\u0442\u0430\u0432\u043a\u0438      * @param isLast \u0424\u043b\u0430\u0433 \u043d\u0430\u0445\u043e\u0436\u0434\u0435\u043d\u0438\u044f \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439 \u043d\u0430 \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0435\u0439 \u043f\u043e\u0437\u0438\u0446\u0438\u0438 \u0441\u0440\u0435\u0434\u0438 \u043e\u0441\u0442\u0430\u043b\u044c\u043d\u044b\u0445      * @return \u0421\u0442\u0440\u043e\u043a\u0443 \u0441 \u043f\u0435\u0440\u0435\u0447\u043d\u0435\u043c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439 \u0434\u043b\u044f \u0437\u0430\u043f\u0440\u043e\u0441\u0430 insert      *\/     private String buildInsertValues (String[] columns, HashMap&lt;String, String&gt; data, boolean isLast) {         String vals = \"(\";          for (int i = 0; i &lt; columns.length - 1; i++) {             vals = vals.concat(data.get(columns[i]).concat(\", \"));         }          vals = vals.concat(data.get(columns[columns.length-1]).concat(\")\"));          if (isLast) {             vals = vals.concat(\";\");         }         else         {             vals = vals.concat(\", \");         }          return vals;     }<\/code><\/pre>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c, \u0438\u043c\u0435\u044f \u0432\u0441\u0435 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b\u0435 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u044b, \u043f\u0435\u0440\u0435\u0439\u0434\u0451\u043c \u043a \u0440\u0435\u0448\u0435\u043d\u0438\u044e \u043d\u0430\u0448\u0435\u0439 \u0437\u0430\u0434\u0430\u0447\u0438. \u0412 \u0440\u0430\u043c\u043a\u0430\u0445 \u0430\u0431\u0441\u0442\u0440\u0430\u043a\u0446\u0438\u0438 \u0437\u0430\u043c\u0435\u043d\u0438\u043c \u0441\u043b\u043e\u0436\u043d\u044b\u0435 \u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u044f \u043d\u0430 \u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u044f \u0441\u0443\u043c\u043c\u044b \u0438 \u0440\u0430\u0437\u043d\u043e\u0441\u0442\u0438 \u0434\u0432\u0443\u0445 \u0447\u0438\u0441\u0435\u043b. \u0418\u0442\u043e\u0433\u043e\u0432\u044b\u0439 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c \u0437\u0430\u043a\u043b\u044e\u0447\u0430\u0435\u0442\u0441\u044f \u0432 \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u0438 \u0434\u0432\u0443\u0445 \u0447\u0438\u0441\u0435\u043b \u0438\u0437 \u043e\u0434\u043d\u043e\u0439 \u0442\u0430\u0431\u043b\u0438\u0446\u044b, \u043f\u0440\u043e\u0432\u0435\u0434\u0435\u043d\u0438\u0438 \u0440\u0430\u0441\u0447\u0435\u0442\u043e\u0432, \u0432\u0441\u0442\u0430\u0432\u043a\u0435 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0430 \u0432 \u043d\u043e\u0432\u0443\u044e \u0442\u0430\u0431\u043b\u0438\u0446\u0443. \u0421 \u0443\u0447\u0451\u0442\u043e\u043c \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u0430 \u0440\u0435\u0448\u0435\u043d\u0438\u044f \u043d\u0430\u0448\u0435\u0439 \u0437\u0430\u0434\u0430\u0447\u0438 MainClass \u0438\u0437 \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0435\u0439 \u0441\u0442\u0430\u0442\u044c\u0438 \u0431\u0443\u0434\u0435\u0442 \u0432\u044b\u0433\u043b\u044f\u0434\u0435\u0442\u044c \u0442\u0430\u043a:  <\/p>\n<pre><code>package DataBaseTools;  import java.sql.ResultSet; import java.sql.SQLException; import java.util.HashMap; import java.util.Vector;  public class MainClass {      public static void main(String[] args) throws SQLException {         \/\/ create instance         DBC dbc = new DBC(\"localhost\", \"testDB\");           \/\/ get query response         ResultSet response = dbc.execQuerySelect(\"x, y\", \"digits\",);           Vector&lt;HashMap&lt;String, String&gt;&gt; insertBuffer = new Vector&lt;HashMap&lt;String, String&gt;&gt;();          \/\/ handle received data         if (response == null) {             System.out.println(\"NULL\");         } else {             while (response.next()) {                 HashMap&lt;String, String&gt; rowData = new HashMap&lt;String, String&gt;();  \t\t\t\tint x = response.getInt(\"x\"); \t\t\t\tint y = response.getInt(\"y\"); \t\t\t\t \t\t\t\tint a = x + y; \t\t\t\tint s = x - y; \t\t\t\t \t\t\t\trowData.put(\"a\", a.toString()); \t\t\t\trowData.put(\"s\", s.toString());                  insertBuffer.add(rowData);                  if (insertBuffer.size() == 1000) {                     String[] cols = {\"a\", \"s\"};                      System.out.println(dbc.execQueryInsert(\"[results]\", cols, insertBuffer));                      insertBuffer.clear();                 }             }              if (insertBuffer.size() &gt; 0) {                 String[] cols = {\"a\", \"s\"};                  System.out.println(dbc.execQueryInsert(\"[results]\", cols, insertBuffer));                  insertBuffer.clear();             }         }      } }<\/code><\/pre>\n<p>\u042d\u0442\u043e\u0442 \u043a\u043e\u0434 \u0441\u043e\u0437\u0434\u0430\u0451\u0442 \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435 \u043a \u0431\u0430\u0437\u0435, \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u0442 \u0434\u0430\u043d\u043d\u044b\u0435 \u0438\u0437 \u0438\u0441\u0445\u043e\u0434\u043d\u043e\u0439 \u0442\u0430\u0431\u043b\u0438\u0446\u044b, \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442 \u0440\u0430\u0441\u0447\u0435\u0442 \u0438 \u0437\u0430\u043f\u0438\u0441\u044c \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0430 \u0432 \u0431\u0443\u0444\u0435\u0440, \u0430 \u043f\u0440\u0438 \u043d\u0430\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0438 \u0431\u0443\u0444\u0435\u0440\u0430 \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u0437\u0430\u043f\u0438\u0441\u044c \u0432 \u0431\u0430\u0437\u0443. \u041f\u043e\u0441\u043b\u0435 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u0446\u0438\u043a\u043b\u0430 \u043e\u0441\u0442\u0430\u0432\u0448\u0438\u0435\u0441\u044f \u0432 \u0431\u0443\u0444\u0435\u0440\u0435 \u0434\u0430\u043d\u043d\u044b\u0435 \u0442\u0430\u043a\u0436\u0435 \u0437\u0430\u043f\u0438\u0441\u044b\u0432\u0430\u044e\u0442\u0441\u044f \u0432 \u0431\u0430\u0437\u0443. \u041e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0430 \u0442\u0430\u043a\u043e\u0433\u043e \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u0430 \u0434\u0430\u043d\u043d\u044b\u0445 \u043f\u0440\u0438 \u0438\u0437\u043d\u0430\u0447\u0430\u043b\u044c\u043d\u043e\u0439 \u0441\u043b\u043e\u0436\u043d\u043e\u0441\u0442\u0438 \u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u0439 \u0437\u0430\u043d\u044f\u043b\u0430 \u0447\u0443\u0442\u044c \u0431\u043e\u043b\u0435\u0435 7 \u0447\u0430\u0441\u043e\u0432, \u0447\u0442\u043e \u043c\u0438\u043d\u0438\u043c\u0443\u043c \u0432 4 \u0440\u0430\u0437\u0430 \u0431\u044b\u0441\u0442\u0440\u0435\u0435 \u0430\u043d\u0430\u043b\u043e\u0433\u0438\u0447\u043d\u043e\u0433\u043e \u043a\u043e\u0434\u0430 \u043d\u0430 Python. \u041f\u0440\u0438 \u0443\u0432\u0435\u043b\u0438\u0447\u0435\u043d\u0438\u0438 \u0441\u043a\u043e\u0440\u043e\u0441\u0442\u0438 \u0440\u0430\u0431\u043e\u0442\u044b \u0441 \u0411\u0414 \u0442\u0430\u043a\u043e\u0435 \u0440\u0435\u0448\u0435\u043d\u0438\u0435 \u043f\u043e\u0437\u0432\u043e\u043b\u0438\u0442 \u0443\u0432\u0435\u043b\u0438\u0447\u0438\u0442\u044c \u0441\u043b\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u0439, \u043d\u0435 \u0443\u0432\u0435\u043b\u0438\u0447\u0438\u0432\u0430\u044f \u0432\u0440\u0435\u043c\u044f \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f.  <\/p>\n<\/div>\n<p> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/post\/564654\/\"> https:\/\/habr.com\/ru\/post\/564654\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"\n<div class=\"post__text post__text_v2\" id=\"post-content-body\">\n<figure class=\"full-width\"><figcaption><\/figcaption><\/figure>\n<p>\u0412&nbsp;<a href=\"https:\/\/habr.com\/ru\/post\/564648\/\" rel=\"noopener noreferrer nofollow\">\u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0435\u0439 \u0441\u0442\u0430\u0442\u044c\u0435<\/a>&nbsp;\u043c\u044b \u0443\u043f\u043e\u043c\u0438\u043d\u0430\u043b\u0438 \u043e Java + JDBC \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u0430\u043b\u044c\u0442\u0435\u0440\u043d\u0430\u0442\u0438\u0432\u044b Python + ODBC. \u0412 \u044d\u0442\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u043f\u0440\u0438\u0432\u0435\u0434\u0451\u043c \u0443\u0441\u043b\u043e\u0432\u043d\u0443\u044e \u0441\u0438\u0442\u0443\u0430\u0446\u0438\u044e, \u043f\u0440\u0438\u0431\u043b\u0438\u0436\u0435\u043d\u043d\u0443\u044e \u043a \u0442\u043e\u0439, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u043f\u043e\u0431\u0443\u0434\u0438\u043b\u0430 \u043d\u0430\u0441 \u0441\u043c\u0435\u043d\u0438\u0442\u044c \u044f\u0437\u044b\u043a \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f.<\/p>\n<p>\u0411\u044b\u043b\u0430 \u043f\u043e\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0430 \u0437\u0430\u0434\u0430\u0447\u0430 \u043f\u043e \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0435 \u0431\u043e\u043b\u0435\u0435 25 \u043c\u043b\u043d. \u0441\u0442\u0440\u043e\u043a \u043f\u043e\u0441\u0440\u0435\u0434\u0441\u0442\u0432\u043e\u043c \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0430 ETL: \u043d\u0430 \u043e\u0441\u043d\u043e\u0432\u0435 \u0438\u043c\u0435\u044e\u0449\u0438\u0445\u0441\u044f \u0434\u0430\u043d\u043d\u044b\u0445 \u0440\u0430\u0441c\u0447\u0438\u0442\u0430\u0442\u044c \u0434\u0432\u0430 \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0445 \u0441\u0442\u043e\u043b\u0431\u0446\u0430 \u0438 \u0432\u0435\u0440\u043d\u0443\u0442\u044c \u0438\u0445 \u0432 \u0431\u0430\u0437\u0443. Python \u043f\u0440\u0435\u043a\u0440\u0430\u0441\u043d\u043e \u0441\u043f\u0440\u0430\u0432\u043b\u044f\u043b\u0441\u044f \u0441 \u043f\u043e\u0434\u043e\u0431\u043d\u044b\u043c\u0438 \u0437\u0430\u0434\u0430\u0447\u0430\u043c\u0438, \u043d\u043e \u0432 \u0434\u0430\u043d\u043d\u043e\u0439 \u0441\u0438\u0442\u0443\u0430\u0446\u0438\u0438 \u0441\u043a\u043e\u0440\u043e\u0441\u0442\u044c \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u044f \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0430 \u0431\u044b\u043b\u0430 \u043d\u0435 \u0441\u0430\u043c\u043e\u0439 \u043e\u043f\u0442\u0438\u043c\u0430\u043b\u044c\u043d\u043e\u0439: \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0430 \u0434\u043b\u0438\u043b\u0430\u0441\u044c \u0431\u043e\u043b\u0435\u0435 \u0441\u0443\u0442\u043e\u043a.<\/p>\n<p>\u0422\u0430\u043a \u043a\u0430\u043a \u043f\u0440\u043e\u0446\u0435\u0434\u0443\u0440\u0443 \u043f\u0440\u0435\u0434\u043f\u043e\u043b\u0430\u0433\u0430\u043b\u043e\u0441\u044c \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0442\u044c \u043c\u043d\u043e\u0433\u043e\u043a\u0440\u0430\u0442\u043d\u043e, \u0442\u043e \u0431\u044b\u043b\u043e \u0440\u0435\u0448\u0435\u043d\u043e \u043d\u0430\u0439\u0442\u0438 \u0431\u043e\u043b\u0435\u0435 \u0431\u044b\u0441\u0442\u0440\u044b\u0439 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442. \u041f\u043e\u0438\u0441\u043a \u0430\u043b\u044c\u0442\u0435\u0440\u043d\u0430\u0442\u0438\u0432\u043d\u044b\u0445 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a \u0434\u043b\u044f Python \u043d\u0438 \u043a \u0447\u0435\u043c\u0443 \u043d\u0435 \u043f\u0440\u0438\u0432\u0451\u043b. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u0431\u044b\u043b\u043e \u0440\u0435\u0448\u0435\u043d\u043e \u043f\u0440\u0438\u043c\u0435\u043d\u0438\u0442\u044c \u0442\u044f\u0436\u0451\u043b\u0443\u044e \u0430\u0440\u0442\u0438\u043b\u043b\u0435\u0440\u0438\u044e \u2014 Java, \u0442\u0430\u043a \u043a\u0430\u043a Java \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u0441 \u0411\u0414 \u0431\u044b\u0441\u0442\u0440\u0435\u0435, \u0447\u0435\u043c Python \u0447\u0438\u0441\u0442\u043e \u0442\u0435\u0445\u043d\u0438\u0447\u0435\u0441\u043a\u0438. \u0418 \u0447\u0435\u043c \u0431\u043e\u043b\u044c\u0448\u0435 \u043e\u0431\u044a\u0451\u043c \u0434\u0430\u043d\u043d\u044b\u0445, \u0442\u0435\u043c \u0437\u0430\u043c\u0435\u0442\u043d\u0435\u0435 \u0440\u0435\u0430\u043b\u0438\u0437\u0443\u0435\u0442\u0441\u044f \u044d\u0442\u043e \u043f\u0440\u0435\u0438\u043c\u0443\u0449\u0435\u0441\u0442\u0432\u043e.<\/p>\n<p>\u041d\u0430 \u043f\u0435\u0440\u0432\u043e\u043c \u044d\u0442\u0430\u043f\u0435 \u0440\u0430\u0437\u043e\u0432\u044c\u0451\u043c \u043a\u043b\u0430\u0441\u0441 DBC \u0438\u0437 \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0435\u0439 \u0441\u0442\u0430\u0442\u044c\u0438, \u0434\u043e\u0431\u0430\u0432\u0438\u0432:<\/p>\n<ol>\n<li>\n<p>\u043c\u0435\u0442\u043e\u0434 execQuerySelect \u0434\u043b\u044f \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f select-\u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432 \u0432 \u0440\u0430\u0437\u043d\u044b\u0445 \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u0430\u0445 (\u0441 TOP, where \u0438 \u0442.\u0434.)<\/p>\n<\/li>\n<li>\n<p>\u043c\u0435\u0442\u043e\u0434 execQueryInsert \u0434\u043b\u044f \u0432\u0441\u0442\u0430\u0432\u043a\u0438 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0430 \u0432 \u0411\u0414<\/p>\n<\/li>\n<li>\n<p>\u0432\u0441\u043f\u043e\u043c\u043e\u0433\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u043c\u0435\u0442\u043e\u0434\u0430 buildInsertColumns \u0438 buildInsertValues \u0434\u043b\u044f \u0444\u043e\u0440\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u043a\u043e\u043b\u043e\u043d\u043e\u043a \u0438 \u0441\u0442\u0440\u043e\u043a \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0435\u043d\u043d\u043e.<\/p>\n<\/li>\n<\/ol>\n<p>\u0412 \u0438\u0442\u043e\u0433\u0435 \u043a\u043b\u0430\u0441\u0441 DBC \u043f\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0441\u044f \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u043a\u043e\u0434\u043e\u043c:<\/p>\n<pre><code>\/**      * \u0412\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435 select \u0437\u0430\u043f\u0440\u043e\u0441\u0430 \u043a \u0411\u0414      *      * @param select \u041d\u0430\u0437\u0432\u0430\u043d\u0438\u044f \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b\u0445 \u043a\u043e\u043b\u043e\u043d\u043e\u043a (* - \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0432\u0441\u0435)      * @param from   \u0422\u0430\u0431\u043b\u0438\u0446\u0430 \u0438\u0437 \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u043d\u0435\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0434\u0430\u043d\u043d\u044b\u0435      * @return ResultSet \u0441 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0430\u043c\u0438 \u0440\u0430\u0431\u043e\u0442\u044b \u0437\u0430\u043f\u0440\u043e\u0441\u0430      *\/     public ResultSet execQuerySelect(String select, String from) {         if (!readyToWork) {             System.err.println(\"DBC not ready to work! Abort:execQuerySelected\");             return null;         }          String query = \"SELECT \" + select + \" FROM \" + from;          return execQuery(query);     }      \/**      * \u0412\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435 select \u0437\u0430\u043f\u0440\u043e\u0441\u0430 \u043a \u0411\u0414      *      * @param select \u041d\u0430\u0437\u0432\u0430\u043d\u0438\u044f \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b\u0445 \u043a\u043e\u043b\u043e\u043d\u043e\u043a (* - \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0432\u0441\u0435)      * @param from   \u0422\u0430\u0431\u043b\u0438\u0446\u0430 \u0438\u0437 \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u043d\u0435\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0434\u0430\u043d\u043d\u044b\u0435      * @param top    \u041a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \"\u0432\u0435\u0440\u0445\u043d\u0438\u0445\" \u0441\u0442\u0440\u043e\u043a \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c\u044b\u0445 \u0438\u0437 \u0431\u0430\u0437\u044b      * @return ResultSet \u0441 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0430\u043c\u0438 \u0440\u0430\u0431\u043e\u0442\u044b \u0437\u0430\u043f\u0440\u043e\u0441\u0430      *\/     public ResultSet execQuerySelect(String select, String from, Integer top) {         if (!readyToWork) {             System.err.println(\"DBC not ready to work! Abort:execQuerySelected\");             return null;         }          String query = \"SELECT TOP(\" + top + \") \" + select + \" FROM \" + from;          return execQuery(query);     }      \/**      * \u0412\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435 select \u0437\u0430\u043f\u0440\u043e\u0441\u0430 \u043a \u0411\u0414      *      * @param select \u041d\u0430\u0437\u0432\u0430\u043d\u0438\u044f \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b\u0445 \u043a\u043e\u043b\u043e\u043d\u043e\u043a (* - \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0432\u0441\u0435)      * @param from   \u0422\u0430\u0431\u043b\u0438\u0446\u0430 \u0438\u0437 \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u043d\u0435\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0434\u0430\u043d\u043d\u044b\u0435      * @param where  \u0423\u0441\u043b\u043e\u0432\u0438\u0435 \u0432\u044b\u0431\u043e\u0440\u043a\u0438 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439 \u0438\u0437 \u0442\u0430\u0431\u043b\u0438\u0446\u044b      * @return ResultSet \u0441 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0430\u043c\u0438 \u0440\u0430\u0431\u043e\u0442\u044b \u0437\u0430\u043f\u0440\u043e\u0441\u0430      *\/     public ResultSet execQuerySelect(String select, String from, String where) {         if (!readyToWork) {             System.err.println(\"DBC not ready to work! Abort:execQuerySelected\");             return null;         }          String query = \"SELECT \" + select + \" FROM \" + from + \" WHERE \" + where;          return execQuery(query);     }      \/**      * \u0412\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435 select \u0437\u0430\u043f\u0440\u043e\u0441\u0430 \u043a \u0411\u0414      *      * @param select \u041d\u0430\u0437\u0432\u0430\u043d\u0438\u044f \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b\u0445 \u043a\u043e\u043b\u043e\u043d\u043e\u043a (* - \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0432\u0441\u0435)      * @param from   \u0422\u0430\u0431\u043b\u0438\u0446\u0430 \u0438\u0437 \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u043d\u0435\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0434\u0430\u043d\u043d\u044b\u0435      * @param where  \u0423\u0441\u043b\u043e\u0432\u0438\u0435 \u0432\u044b\u0431\u043e\u0440\u043a\u0438 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439 \u0438\u0437 \u0442\u0430\u0431\u043b\u0438\u0446\u044b      * @param top    \u041a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \"\u0432\u0435\u0440\u0445\u043d\u0438\u0445\" \u0441\u0442\u0440\u043e\u043a \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c\u044b\u0445 \u0438\u0437 \u0431\u0430\u0437\u044b      * @return ResultSet \u0441 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0430\u043c\u0438 \u0440\u0430\u0431\u043e\u0442\u044b \u0437\u0430\u043f\u0440\u043e\u0441\u0430      *\/     public ResultSet execQuerySelect(String select, String from, String where, Integer top) {         if (!readyToWork) {             System.err.println(\"DBC not ready to work! Abort:execQuerySelected\");             return null;         }          String query = \"SELECT TOP(\" + top + \") \" + select + \" FROM \" + from + \" WHERE \" + where;          return execQuery(query);     }      \/**      * \u0412\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435 insert \u0437\u0430\u043f\u0440\u043e\u0441\u0430 \u043a \u0411\u0414      *      * @param table \u0418\u043c\u044f \u0442\u0430\u0431\u043b\u0438\u0446\u044b \u0434\u043b\u044f \u0432\u0441\u0442\u0430\u0432\u043a\u0438      * @param columns \u041c\u0430\u0441\u0441\u0438\u0432 \u043a\u043e\u043b\u043e\u043d\u043e\u043a \u0434\u043b\u044f \u0432\u0441\u0442\u0430\u0432\u043a\u0438      * @param data \u0412\u0435\u043a\u0442\u043e\u0440 \u0441\u043b\u043e\u0432\u0430\u0440\u0435\u0439 \u0441\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f\u043c\u0438 \u0434\u043b\u044f \u0432\u0441\u0442\u0430\u0432\u043a\u0438      * @return \u0424\u043b\u0430\u0433 \u0443\u0441\u043f\u0435\u0448\u043d\u043e\u0441\u0442\u0438 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u0437\u0430\u043f\u0440\u043e\u0441\u0430      *\/     public boolean execQueryInsert(String table, String[] columns, Vector&lt;HashMap&lt;String, String&gt;&gt; data) {         if (!readyToWork) {             System.err.println(\"DBC not ready to work! Abort:execQuerySelected\");             return false;         }          String query = \"INSERT INTO \" + table + \" \" + buildInsertColumns(columns) + \" VALUES \";          for (int i = 0; i &lt; data.size() - 1; i++) {             query = query.concat(buildInsertValues(columns, data.get(i), false));         }          query = query.concat(buildInsertValues(columns, data.get(data.size() - 1), true));          execQuery(query);         return true;     } \t \t    \/**      * \u0424\u043e\u0440\u043c\u0438\u0440\u0443\u0435\u0442 \u0441\u0442\u0440\u043e\u043a\u0443 \u0441 \u043f\u0435\u0440\u0435\u0447\u043d\u0435\u043c \u043a\u043e\u043b\u043e\u043d\u043e\u043a \u0434\u043b\u044f \u0437\u0430\u043f\u0440\u043e\u0441\u0430 insert      *      * @param columns \u041c\u0430\u0441\u0441\u0438\u0432 \u043a\u043e\u043b\u043e\u043d\u043e\u043a      * @return \u0421\u0442\u0440\u043e\u043a\u0443 \u0441 \u043f\u0435\u0440\u0435\u0447\u043d\u0435\u043c \u043a\u043e\u043b\u043e\u043d\u043e\u043a \u0434\u043b\u044f \u0437\u0430\u043f\u0440\u043e\u0441\u0430 insert      *\/     private String buildInsertColumns (String[] columns) {          String r = \"(\";          for (int i = 0; i &lt; columns.length - 1; i++) {             r = r.concat(\"[\" + columns[i] + \"], \");         }          r = r.concat(\"[\" + columns[columns.length-1] + \"])\");          return r;     }      \/**      * \u0424\u043e\u0440\u043c\u0438\u0440\u0443\u0435\u0442 \u0441\u0442\u0440\u043e\u043a\u0443 \u0441 \u043f\u0435\u0440\u0435\u0447\u043d\u0435\u043c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439 \u0434\u043b\u044f \u0437\u0430\u043f\u0440\u043e\u0441\u0430 insert      *      * @param columns \u041c\u0430\u0441\u0441\u0438\u0432 \u043a\u043e\u043b\u043e\u043d\u043e\u043a      * @param data \u0421\u043b\u043e\u0432\u0430\u0440\u044c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439 \u0434\u043b\u044f \u0432\u0441\u0442\u0430\u0432\u043a\u0438      * @param isLast \u0424\u043b\u0430\u0433 \u043d\u0430\u0445\u043e\u0436\u0434\u0435\u043d\u0438\u044f \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439 \u043d\u0430 \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0435\u0439 \u043f\u043e\u0437\u0438\u0446\u0438\u0438 \u0441\u0440\u0435\u0434\u0438 \u043e\u0441\u0442\u0430\u043b\u044c\u043d\u044b\u0445      * @return \u0421\u0442\u0440\u043e\u043a\u0443 \u0441 \u043f\u0435\u0440\u0435\u0447\u043d\u0435\u043c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439 \u0434\u043b\u044f \u0437\u0430\u043f\u0440\u043e\u0441\u0430 insert      *\/     private String buildInsertValues (String[] columns, HashMap&lt;String, String&gt; data, boolean isLast) {         String vals = \"(\";          for (int i = 0; i &lt; columns.length - 1; i++) {             vals = vals.concat(data.get(columns[i]).concat(\", \"));         }          vals = vals.concat(data.get(columns[columns.length-1]).concat(\")\"));          if (isLast) {             vals = vals.concat(\";\");         }         else         {             vals = vals.concat(\", \");         }          return vals;     }<\/code><\/pre>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c, \u0438\u043c\u0435\u044f \u0432\u0441\u0435 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b\u0435 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u044b, \u043f\u0435\u0440\u0435\u0439\u0434\u0451\u043c \u043a \u0440\u0435\u0448\u0435\u043d\u0438\u044e \u043d\u0430\u0448\u0435\u0439 \u0437\u0430\u0434\u0430\u0447\u0438. \u0412 \u0440\u0430\u043c\u043a\u0430\u0445 \u0430\u0431\u0441\u0442\u0440\u0430\u043a\u0446\u0438\u0438 \u0437\u0430\u043c\u0435\u043d\u0438\u043c \u0441\u043b\u043e\u0436\u043d\u044b\u0435 \u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u044f \u043d\u0430 \u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u044f \u0441\u0443\u043c\u043c\u044b \u0438 \u0440\u0430\u0437\u043d\u043e\u0441\u0442\u0438 \u0434\u0432\u0443\u0445 \u0447\u0438\u0441\u0435\u043b. \u0418\u0442\u043e\u0433\u043e\u0432\u044b\u0439 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c \u0437\u0430\u043a\u043b\u044e\u0447\u0430\u0435\u0442\u0441\u044f \u0432 \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u0438 \u0434\u0432\u0443\u0445 \u0447\u0438\u0441\u0435\u043b \u0438\u0437 \u043e\u0434\u043d\u043e\u0439 \u0442\u0430\u0431\u043b\u0438\u0446\u044b, \u043f\u0440\u043e\u0432\u0435\u0434\u0435\u043d\u0438\u0438 \u0440\u0430\u0441\u0447\u0435\u0442\u043e\u0432, \u0432\u0441\u0442\u0430\u0432\u043a\u0435 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0430 \u0432 \u043d\u043e\u0432\u0443\u044e \u0442\u0430\u0431\u043b\u0438\u0446\u0443. \u0421 \u0443\u0447\u0451\u0442\u043e\u043c \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u0430 \u0440\u0435\u0448\u0435\u043d\u0438\u044f \u043d\u0430\u0448\u0435\u0439 \u0437\u0430\u0434\u0430\u0447\u0438 MainClass \u0438\u0437 \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0435\u0439 \u0441\u0442\u0430\u0442\u044c\u0438 \u0431\u0443\u0434\u0435\u0442 \u0432\u044b\u0433\u043b\u044f\u0434\u0435\u0442\u044c \u0442\u0430\u043a:  <\/p>\n<pre><code>package DataBaseTools;  import java.sql.ResultSet; import java.sql.SQLException; import java.util.HashMap; import java.util.Vector;  public class MainClass {      public static void main(String[] args) throws SQLException {         \/\/ create instance         DBC dbc = new DBC(\"localhost\", \"testDB\");           \/\/ get query response         ResultSet response = dbc.execQuerySelect(\"x, y\", \"digits\",);           Vector&lt;HashMap&lt;String, String&gt;&gt; insertBuffer = new Vector&lt;HashMap&lt;String, String&gt;&gt;();          \/\/ handle received data         if (response == null) {             System.out.println(\"NULL\");         } else {             while (response.next()) {                 HashMap&lt;String, String&gt; rowData = new HashMap&lt;String, String&gt;();  \t\t\t\tint x = response.getInt(\"x\"); \t\t\t\tint y = response.getInt(\"y\"); \t\t\t\t \t\t\t\tint a = x + y; \t\t\t\tint s = x - y; \t\t\t\t \t\t\t\trowData.put(\"a\", a.toString()); \t\t\t\trowData.put(\"s\", s.toString());                  insertBuffer.add(rowData);                  if (insertBuffer.size() == 1000) {                     String[] cols = {\"a\", \"s\"};                      System.out.println(dbc.execQueryInsert(\"[results]\", cols, insertBuffer));                      insertBuffer.clear();                 }             }              if (insertBuffer.size() &gt; 0) {                 String[] cols = {\"a\", \"s\"};                  System.out.println(dbc.execQueryInsert(\"[results]\", cols, insertBuffer));                  insertBuffer.clear();             }         }      } }<\/code><\/pre>\n<p>\u042d\u0442\u043e\u0442 \u043a\u043e\u0434 \u0441\u043e\u0437\u0434\u0430\u0451\u0442 \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435 \u043a \u0431\u0430\u0437\u0435, \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u0442 \u0434\u0430\u043d\u043d\u044b\u0435 \u0438\u0437 \u0438\u0441\u0445\u043e\u0434\u043d\u043e\u0439 \u0442\u0430\u0431\u043b\u0438\u0446\u044b, \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442 \u0440\u0430\u0441\u0447\u0435\u0442 \u0438 \u0437\u0430\u043f\u0438\u0441\u044c \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0430 \u0432 \u0431\u0443\u0444\u0435\u0440, \u0430 \u043f\u0440\u0438 \u043d\u0430\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0438 \u0431\u0443\u0444\u0435\u0440\u0430 \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u0437\u0430\u043f\u0438\u0441\u044c \u0432 \u0431\u0430\u0437\u0443. \u041f\u043e\u0441\u043b\u0435 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u0446\u0438\u043a\u043b\u0430 \u043e\u0441\u0442\u0430\u0432\u0448\u0438\u0435\u0441\u044f \u0432 \u0431\u0443\u0444\u0435\u0440\u0435 \u0434\u0430\u043d\u043d\u044b\u0435 \u0442\u0430\u043a\u0436\u0435 \u0437\u0430\u043f\u0438\u0441\u044b\u0432\u0430\u044e\u0442\u0441\u044f \u0432 \u0431\u0430\u0437\u0443. \u041e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0430 \u0442\u0430\u043a\u043e\u0433\u043e \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u0430 \u0434\u0430\u043d\u043d\u044b\u0445 \u043f\u0440\u0438 \u0438\u0437\u043d\u0430\u0447\u0430\u043b\u044c\u043d\u043e\u0439 \u0441\u043b\u043e\u0436\u043d\u043e\u0441\u0442\u0438 \u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u0439 \u0437\u0430\u043d\u044f\u043b\u0430 \u0447\u0443\u0442\u044c \u0431\u043e\u043b\u0435\u0435 7 \u0447\u0430\u0441\u043e\u0432, \u0447\u0442\u043e \u043c\u0438\u043d\u0438\u043c\u0443\u043c \u0432 4 \u0440\u0430\u0437\u0430 \u0431\u044b\u0441\u0442\u0440\u0435\u0435 \u0430\u043d\u0430\u043b\u043e\u0433\u0438\u0447\u043d\u043e\u0433\u043e \u043a\u043e\u0434\u0430 \u043d\u0430 Python. \u041f\u0440\u0438 \u0443\u0432\u0435\u043b\u0438\u0447\u0435\u043d\u0438\u0438 \u0441\u043a\u043e\u0440\u043e\u0441\u0442\u0438 \u0440\u0430\u0431\u043e\u0442\u044b \u0441 \u0411\u0414 \u0442\u0430\u043a\u043e\u0435 \u0440\u0435\u0448\u0435\u043d\u0438\u0435 \u043f\u043e\u0437\u0432\u043e\u043b\u0438\u0442 \u0443\u0432\u0435\u043b\u0438\u0447\u0438\u0442\u044c \u0441\u043b\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u0439, \u043d\u0435 \u0443\u0432\u0435\u043b\u0438\u0447\u0438\u0432\u0430\u044f \u0432\u0440\u0435\u043c\u044f \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f.  <\/p>\n<\/div>\n<p> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/post\/564654\/\"> https:\/\/habr.com\/ru\/post\/564654\/<\/a><br \/><\/br><\/br><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-325545","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/325545","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=325545"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/325545\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=325545"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=325545"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=325545"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}