フィルターのクリア

How to handle a database connection (mysql) in loops (for and parfor)?

2 ビュー (過去 30 日間)
Léon
Léon 2013 年 6 月 1 日
コメント済み: TIANTIANBABA 2021 年 1 月 17 日
Hello,
I already got a working code that does exactly this (see below). But I have to big problem that it is too slow. So I want to use that in parfor to speed it up and would be happy if you can give me hint of how to write the code using for parfor, many thanks.
%%"for-loop" version
db = 'my_database';
user = 'matlab';
password = '1234';
host = '100.200.300.4';
conn = database(db, user, password,'com.mysql.jdbc.Driver',['jdbc:mysql://' host ':3306/' db]);
setdbprefs('DataReturnFormat','cellarray');
for i = 1:1000
SQL = ['SELECT * FROM `my_table`;'];
e = exec(conn,SQL);
e = fetch(e);
data = e.Data;
end
close(conn)
  2 件のコメント
Taufik Sutanto
Taufik Sutanto 2013 年 10 月 13 日
I have been trying to do this too ... However, it seems that the JDBC driver is not supporting the parallel process.
TIANTIANBABA
TIANTIANBABA 2021 年 1 月 17 日
Did you find an anseer yet? It seems to me that exec and fetch can not work inside a parfor-loop.

サインインしてコメントする。

回答 (1 件)

Léon
Léon 2013 年 6 月 5 日
No one got an idea? :-(

カテゴリ

Help Center および File ExchangeDatabase Toolbox についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by