Comments on: Speeding up Matlab-JDBC SQL queries https://undocumentedmatlab.com/blog_old/speeding-up-matlab-jdbc-sql-queries Charting Matlab's unsupported hidden underbelly Mon, 25 Apr 2022 12:26:16 +0000 hourly 1 https://wordpress.org/?v=4.4.1 By: Jeremyhttps://undocumentedmatlab.com/blog_old/speeding-up-matlab-jdbc-sql-queries#comment-499395 Mon, 23 Sep 2019 16:57:38 +0000 https://undocumentedmatlab.com/?p=6742#comment-499395 Yair,

Thank you for your work, most likely buying the book soon. But in the meantime I’m hitting a snag on setting up the JDBC connection on the fly. Can you provide a bit more explanation and or hints on the steps required? I can use database toolbox to do the setup and it works just fine, but I would rather be able to hardcode it so that my application/code is portable.

]]>
By: Paulhttps://undocumentedmatlab.com/blog_old/speeding-up-matlab-jdbc-sql-queries#comment-406321 Mon, 08 May 2017 23:19:17 +0000 https://undocumentedmatlab.com/?p=6742#comment-406321 Hey there,

just wanted to say thank you for this page. I found a lot of valuable information here how to handle result sets from java in matlab.

Best Regards
Paul

]]>
By: Yair Altmanhttps://undocumentedmatlab.com/blog_old/speeding-up-matlab-jdbc-sql-queries#comment-393990 Tue, 22 Nov 2016 06:43:30 +0000 https://undocumentedmatlab.com/?p=6742#comment-393990 Try to close the ResultSet and stmt (as I’ve shown in the post) after you’ve used them, in order to clear the cache between subsequent JDBC calls, otherwise they might remain in memory and cause an eventual heap-memory error.

]]>
By: Yair Altmanhttps://undocumentedmatlab.com/blog_old/speeding-up-matlab-jdbc-sql-queries#comment-393949 Mon, 21 Nov 2016 16:57:25 +0000 https://undocumentedmatlab.com/?p=6742#comment-393949 I do not believe that JDBC has such an easy-to-use wrapper, unfortunately.

]]>
By: Oleghttps://undocumentedmatlab.com/blog_old/speeding-up-matlab-jdbc-sql-queries#comment-393948 Mon, 21 Nov 2016 16:46:37 +0000 https://undocumentedmatlab.com/?p=6742#comment-393948 I faced this issue with the Matlab Database Toolbox and tackled it by:
* setting the ‘DataReturnFormat’ to ‘numeric’;
* querying results by column and converting the numeric stream into its column format

]]>
By: virnshttps://undocumentedmatlab.com/blog_old/speeding-up-matlab-jdbc-sql-queries#comment-393924 Mon, 21 Nov 2016 10:51:32 +0000 https://undocumentedmatlab.com/?p=6742#comment-393924 Hi
Please help me get rid of “jave heap memory error” in standalone executable (tried both windows and linux versions). I am creating a SQL connection (using JDBC) outside the infinity while loop and then checking with “isopen or isconnection” inside the loop. I read in some forum that the SQL JDBC driver caches the queries which could be the cause. I’ve also tried deleting unused variables in the loop but it didn’t help.

Thanks

]]>
By: aviolovhttps://undocumentedmatlab.com/blog_old/speeding-up-matlab-jdbc-sql-queries#comment-393916 Mon, 21 Nov 2016 08:24:32 +0000 https://undocumentedmatlab.com/?p=6742#comment-393916 Cool,

We do a similar thing using C# and DataTable

import System.Data.DataTable
import System.Data.SqlClient.*
sqlConn = SqlConnection(...);
sqlCmd = SqlCommand(sql_query_string, sqlConn);
sqlAdaptor = SqlDataAdapter(sqlCmd);
dataTable = DataTable();
sqlConn.Open();
sqlAdaptor.Fill(dataTable);
T = dataTable2matlabTable(dataTable); % This does the same column based-fill as in your code.
...

So I’m wondering is it really necessary to make the specific class (JDBC_Fetch.java) to iterate the rows of a ResultSet or does Java not have an equivalent to C#’s DataTable that kind of does that for you, i.e. a data-struct that returns columns instead of rows, roughly speaking, and you can already work on its columns instead of calling rs.next() in an extra for loop? Or maybe the equivalent does not give the necessary speed-up?

best,

]]>