Search Comments and Ratings

go

   
Date File Comment by Comment Rating
27 Jan 2015 Mat file header utilities Utility functions for reading and writing .mat file headers Author: Jonathan Karr

Jonathan Karr

Myles

Myles

5
26 Jun 2014 Coverage Report Generator Generates Cobertura-style XML coverage report Author: Jonathan Karr

Jonathan Karr

Johan Löfberg

Johan Löfberg

Code does work in recent version of MATLAB (r2012,2014 tested) on Windows. The problem is capitalization of drives in which.m vs absolutepath.m.

The first returns C:\... while the second returns c:\...

This causes a failure on line 190 in Coverage.m

Cannot import as done in the example either, so I have to call the method as

report = edu.stanford.covert.test.Coverage('src', '..');

Comment only
10 Jun 2014 queryMySQL Platform independent MySQL database solution with blob support. Author: Jonathan Karr

Jonathan Karr

Romain

Romain

Hi again,

I find my problem with '\n', it's just that Excel generate some CSV file with FIELDS TERMINATED BY '\r\n' and not just '\n'!

Sorry about that !

Comment only
10 Jun 2014 queryMySQL Platform independent MySQL database solution with blob support. Author: Jonathan Karr

Jonathan Karr

Romain

Romain

Nice work here !
Only issue I have with these files is to load a CSV file into a database with lines terminated by '\n' (example : LOAD DATA INFILE 'ExampleFile.csv' INTO TABLE example FIELDS TERMINATED BY ';' LINES TERMINATED BY '\n'.
It looks like there are some problems to find this line return. Indeed the same request works on mysql, and the same request with lines terminated by '!' (for example) works with your package.
I've try to fix this problem but without succes for now.

Anyway thanks for this package !

5
23 Oct 2013 queryMySQL Platform independent MySQL database solution with blob support. Author: Jonathan Karr

Jonathan Karr

John

John

Hi Jonathan- thanks for the useful utility. I've noticed that with these tools, retrieving data from a database takes significantly longer than writing data, even if you try to grab large amounts at once (such as selecting everything in an entire table, which I would think is the most efficent). Running a Matlab profile on the code, it seems that in the function MySQLDatabase.m, line 190 is taking most of the time:
fieldName = this.getValidFieldName(char(metaData.getColumnLabel(i)));

Have you experienced this? Any thoughts on how to speed it up?
Thanks

Comment only
12 Oct 2013 queryMySQL Platform independent MySQL database solution with blob support. Author: Jonathan Karr

Jonathan Karr

Hanan Shteingart

Hanan Shteingart

files which are not part of clean matlab installation are missing:

mkconstarray.m
padarray.m
checkstrs.m

You can find them over the web.

3
26 Jul 2013 queryMySQL Platform independent MySQL database solution with blob support. Author: Jonathan Karr

Jonathan Karr

Jonathan Karr

Jonathan Karr

Hi Carlos,

This is an error with the MySQL Java driver.

Can you share the error? Without seeing the error its hard to say what the problem is.

Best.
Jonathan

Comment only
26 Jul 2013 queryMySQL Platform independent MySQL database solution with blob support. Author: Jonathan Karr

Jonathan Karr

Carlos

Carlos

Hi Jonathan,

Thank you for your reply. The error is in:

Error in ==> MySQLDatabase>MySQLDatabase.open at 409
this.dbConn = driver.connect(url, properties);

Let me know how I can go about fixing this. It seems that it is the Java version used. After I updated my Java, this error takes place.

Many thanks.

Comment only
09 May 2013 queryMySQL Platform independent MySQL database solution with blob support. Author: Jonathan Karr

Jonathan Karr

Jonathan Karr

Jonathan Karr

Hi Carlos,

I've never seen this error before.

First, comment out the try/catch block on lines 402, 410-412. Which line throws the error?

Best
Jonathan

Comment only
09 May 2013 queryMySQL Platform independent MySQL database solution with blob support. Author: Jonathan Karr

Jonathan Karr

Carlos

Carlos

This has been working great on my computer. However, on a newer Mac mini, it gives the following error (I substituted the server details for dummies).

Any ideas?

>> addpath(genpath('MatlabQueryMySQL'))
>> javaaddpath(which('mysql-connector-java-5.1.6-bin.jar'));
import edu.stanford.covert.db.MySQLDatabase;
>> db = MySQLDatabase('server:port', 'dbname', username, password)
Warning: The following error was caught while executing 'edu.stanford.covert.db.MySQLDatabase' class
destructor:
Attempt to reference field of non-structure array.
??? Error using ==> MySQLDatabase>MySQLDatabase.open at 411
Java exception occurred:
java.sql.SQLException: Unknown initial character set index '192' received from server. Initial client
character set can be forced via the 'characterEncoding' property.
at com.mysql.jdbc.Connection.configureClientCharacterSet(Connection.java:2268)
at com.mysql.jdbc.Connection.initializePropsFromServer(Connection.java:3748)
at com.mysql.jdbc.Connection.createNewIO(Connection.java:2585)
at com.mysql.jdbc.Connection.<init>(Connection.java:1485)
at com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:266)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at com.mathworks.jmi.AWTUtilities$Invoker$3.runWithOutput(AWTUtilities.java:443)
at com.mathworks.jmi.AWTUtilities$Invoker$2.watchedRun(AWTUtilities.java:397)
at com.mathworks.jmi.AWTUtilities$WatchedRunnable.run(AWTUtilities.java:360)
at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:209)
at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:708)
at java.awt.EventQueue.access$400(EventQueue.java:82)
at java.awt.EventQueue$2.run(EventQueue.java:669)
at java.awt.EventQueue$2.run(EventQueue.java:667)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.AccessControlContext$1.doIntersectionPrivilege(AccessControlContext.java:87)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:678)
at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:296)
at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:211)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:201)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:196)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:188)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:122)

Error in ==> MySQLDatabase>MySQLDatabase.MySQLDatabase at 72
this.open();

4
01 May 2013 queryMySQL Platform independent MySQL database solution with blob support. Author: Jonathan Karr

Jonathan Karr

Jonathan Karr

Jonathan Karr

Hi Akhmad,

For security reasons we had to lockup our MySQL server, so unfortunately you can't use that test database anymore. The schema is described in test.sql. You can set this up on your own machine. See the examples on line 37-53 for how to work with blobs.

Best.
Jonathan

Comment only
27 Apr 2013 queryMySQL Platform independent MySQL database solution with blob support. Author: Jonathan Karr

Jonathan Karr

AKHMAD FAUZI

AKHMAD FAUZI

[HELP ME]

How i can save my image from Matlab to MySQL database in Type Data BLOB??

Please give me some tutorial with this Code in here,

my email: akhfauz.sisfo@gmail.com

Thanks Verry Much for your help

3
25 Mar 2013 Coverage Report Generator Generates Cobertura-style XML coverage report Author: Jonathan Karr

Jonathan Karr

Jonathan Karr

Jonathan Karr

Sorry for the confusion. I don't believe the Control System Toolbox is required.

Comment only
18 Mar 2013 Coverage Report Generator Generates Cobertura-style XML coverage report Author: Jonathan Karr

Jonathan Karr

James

James

Why is Control System Toolbox required?

Comment only
22 Dec 2012 Empirical formula Class for representing empirical formulae including support for basic math (+, -, *, etc.) Author: Jonathan Karr

Jonathan Karr

Richard Crozier

Richard Crozier

Jonathan, I think this could be a useful piece of code, but you have not documented it. If you have gone to the effort of writing and shareing the code, I suggest going the extra effort to document it so others might be interested in using it.

Comment only
01 Dec 2012 queryMySQL Platform independent MySQL database solution with blob support. Author: Jonathan Karr

Jonathan Karr

Joshua

Joshua

Edit: as a workaround, I nested the function call and added the path before calling the function. For example:

function dataExporter(db,host)
addpath(fullfile(pwd, 'src'));
exportMysqlData(db,host);

Comment only
01 Dec 2012 queryMySQL Platform independent MySQL database solution with blob support. Author: Jonathan Karr

Jonathan Karr

Joshua

Joshua

Works great but I'm having a similar problem. I have to manually add the "src" directory to get it to work. It hasn't been a problem but now that I'm trying to execute it from a command line, I need to modify the path within the function.

I think it may be a problem with MATLAB. It throws a "syntax error" for the import command before running the code, assuming that the path is static.

To see what I'm talking about, try to enable a breakpoint while "src" directory is not in the path.

Comment only
06 Nov 2012 queryMySQL Platform independent MySQL database solution with blob support. Author: Jonathan Karr

Jonathan Karr

Jonathan Karr

Jonathan Karr

Hi George,

Unfortunately our server was attacked recently and I had to lock it down. This means the examples won't work anymore. You'll need to run them on your own MySQL server. The necessary schema is in test.sql.

Best.
Jonathan

Comment only
06 Nov 2012 queryMySQL Platform independent MySQL database solution with blob support. Author: Jonathan Karr

Jonathan Karr

Jonathan Karr

Jonathan Karr

Hi George,

I should also add that you are correct that MATLAB requires that classes be imported after addpath statements are executed. MATLAB will complain if you run the commands together until you've set the path. I usually work around this by setting the MATLAB path at the beginning of the session and then never setting the path inside any other function.

Best.
Jonathan

Comment only
06 Nov 2012 queryMySQL Platform independent MySQL database solution with blob support. Author: Jonathan Karr

Jonathan Karr

George

George

This fails for me.
Running Matlab R2012a, Win64.
When I run the "queryExample.m" code, it returns error:

>> queryExample
"Error: File: queryExample.m Line: 6 Column: 8
Arguments to IMPORT must either end with ".*"
or else specify a fully qualified class name:
"edu.stanford.covert.db.MySQLDatabase" fails this test."

If I run each of the command separately, e.g.
>> addpath(fullfile(pwd, 'src'))
>> javaaddpath('lib/mysql-connector-java-5.1.6/mysql-connector-java-5.1.6-bin.jar')
>> import edu.stanford.covert.db.MySQLDatabase

I do not get the error above. However, then the code fails on the subsequent step:
"
>> db = MySQLDatabase('covertlab.stanford.edu', 'test', 'test', 'test')
Warning: The following error was caught while executing
'edu.stanford.covert.db.MySQLDatabase' class destructor:
Attempt to reference field of non-structure array.
Error using edu.stanford.covert.db.MySQLDatabase/open (line 411)
Java exception occurred:
com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link
failure

Last packet sent to the server was 0 ms ago.

at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)

at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)

...
"

Comment only
19 Jul 2012 queryMySQL Platform independent MySQL database solution with blob support. Author: Jonathan Karr

Jonathan Karr

Agustin

Agustin

Hi Jonathan,

Finally, I have fixed the issue. I's was my fault.

I was doing the import of the java class in each iteration. And the java memory in Matlab was running out.

Now, It's running fine.

Many thanks. It's a great job.

Regards.

Comment only
18 Jul 2012 queryMySQL Platform independent MySQL database solution with blob support. Author: Jonathan Karr

Jonathan Karr

Jonathan Karr

Jonathan Karr

Hi Agustin,

I just tried this example where I repeatedly open and close connections without any issues.

for i = 1:1000
db = MySQLDatabase('covertlab.stanford.edu', 'test', 'test', 'test');
db.prepareStatement('select * from tinytest where id=1');
result = db.query();
assert(~isequal(-1, result));
db.close()
end

Are you working with the most recent version of the code (downloaded after June 22)? I recently changed the way database connections are created based on a suggestion from Matteo. Perhaps you won't have the issue with the newer version.

I'm not sure what the issue is. What happens if you keep the connection open rather than reopening it for each query? I can try to help if you can provide a more complete example of the problem.

Best.
- Jonathan

Comment only
18 Jul 2012 Coverage Report Generator Generates Cobertura-style XML coverage report Author: Jonathan Karr

Jonathan Karr

Eric Moyer

Eric Moyer

I'm running R2010b under Ubuntu 12.04 and example.m gives an error on the import line. When I comment out the import and use the full class name to call edu.stanford.covert.test.Coverage, I get a segmentation fault before it even starts running the constructor code. :-(

Comment only
18 Jul 2012 queryMySQL Platform independent MySQL database solution with blob support. Author: Jonathan Karr

Jonathan Karr

Agustin

Agustin

Hi Jonathan,

It's no problem of machine memory. We have enough.

I have a database with data from hundreds of users and I do 27 queries on each of them. All the queries are 'Select'.

For each user, I open and close the connection to the database.

When I am in the 25th user, I get this error and Matlab crashes. My Matlab version is 7.11 (R2010b).

Do you have any idea?

Thanks

Comment only
17 Jul 2012 queryMySQL Platform independent MySQL database solution with blob support. Author: Jonathan Karr

Jonathan Karr

Jonathan Karr

Jonathan Karr

Hi Agustin,

I just successfully tried this example with a relatively table result set containing 10,000 rows. Are you working with a very large table or on a machine without much memory?

- Jonathan

CREATE TABLE `tinytest` (
`id` int(11) NOT NULL,
`datatiny` tinyint(4) default NULL,
`datasmall` smallint(6) default NULL,
`datamedium` mediumint(9) default NULL,
`dataint` int(11) default NULL,
`databigint` bigint(20) default NULL,
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_general_ci

sql = 'INSERT INTO `test`.`tinytest` (`id`, `datatiny`, `datasmall`, `datamedium`, `dataint`, `databigint`) VALUES ';
for i = 2:10000
sql = [sql sprintf('(%d, %d, %d, %d, %d, %d), ', i, i, i, i, i, i)];
end
sql = sql(1:end-2);

db = MySQLDatabase('covertlab.stanford.edu', 'test', 'test', 'test');
db.prepareStatement(sql);
db.query();

for i = 1:10
db.prepareStatement('select * from tinytest');
result = db.query();
assert(~isequal(-1, result));
end

db.close();

Comment only
17 Jul 2012 queryMySQL Platform independent MySQL database solution with blob support. Author: Jonathan Karr

Jonathan Karr

Jonathan Karr

Jonathan Karr

Hi Agustin,

I can try to help. Can you please clarify your example. What should the result set look like?

Best.
- Jonathan

Comment only
17 Jul 2012 queryMySQL Platform independent MySQL database solution with blob support. Author: Jonathan Karr

Jonathan Karr

Agustin

Agustin

5
17 Jul 2012 queryMySQL Platform independent MySQL database solution with blob support. Author: Jonathan Karr

Jonathan Karr

Agustin

Agustin

Hi Jonathan

Thanks for your help. The problem with the tinyint issue is fixed.

But, now, there is a problem of lack of memory.

After several queries I get the following error:

"Error using ==> MySQLDatabase>SQLDatabase.open at...
Java exception occurred:
java.sql.SQLException: java.lang.OutOfMemoryError: PermGen space..."

This is an example of the queries:

"st3= strcat('SELECT * FROM',' `',tablesq_sm(14),'`');
db.prepareStatement(char(st3(1)));
fieldsqacc = db.query();
assert(~isequal(-1, fieldsqacc));
"

Every time that I change the subject, I close and reopen the database.

"db = MySQLDatabase(...
db.close();"

Do you know where is the problem?

Thanks in advance!

5
28 Jun 2012 queryMySQL Platform independent MySQL database solution with blob support. Author: Jonathan Karr

Jonathan Karr

Benedict

Benedict

5
12 Jun 2012 queryMySQL Platform independent MySQL database solution with blob support. Author: Jonathan Karr

Jonathan Karr

Jonathan Karr

Jonathan Karr

Matteo post deserves a shoutout. I originally tried to create a connection without a java wrapper, but couldn't find a way to achieve this. Great work Matteo for figuring this out and sharing it.
- Jonathan

Comment only
12 Jun 2012 queryMySQL Platform independent MySQL database solution with blob support. Author: Jonathan Karr

Jonathan Karr

Jonathan Karr

Jonathan Karr

Matteo,

Thanks for the suggestion. I'll incorporate this into the next release.
- Jonathan

Comment only
12 Jun 2012 queryMySQL Platform independent MySQL database solution with blob support. Author: Jonathan Karr

Jonathan Karr

Matteo Broggi

Matteo Broggi

Great toolbox!

I have a suggestion for a possible modification.
I managed to avoid the use of the external java wrapper and use only Matlab calls. I modified the private method open() to do this. In this way, you need to set only the mysql jdbc driver in the classpath.

Best,

Matteo

function open(this)
try
properties = java.util.Properties();
properties.setProperty('user',this.userName);
properties.setProperty('password',this.password);
driver = javaObjectEDT('com.mysql.jdbc.Driver');
url = ['jdbc:mysql://' this.hostName '/' this.schema];
this.dbConn = driver.connect(url,properties);
catch exception
throw(MException('MySQLDatabase:mysqlError', char(exception.message)));
end
end

5
07 Jun 2012 queryMySQL Platform independent MySQL database solution with blob support. Author: Jonathan Karr

Jonathan Karr

Pierre

Pierre

5
30 May 2012 queryMySQL Platform independent MySQL database solution with blob support. Author: Jonathan Karr

Jonathan Karr

Jonathan Karr

Jonathan Karr

Samuel and/or Agustin,

I just posted an update which should fix the tinyint issue. Let me know if you have other datatype issues.

Best.
- Jonathan

Comment only
30 May 2012 queryMySQL Platform independent MySQL database solution with blob support. Author: Jonathan Karr

Jonathan Karr

Jonathan Karr

Jonathan Karr

Samuel and/or Agustin,

I can try to help you if you can provide an example of your SQL code.

Best.
- Jonathan

Comment only
29 May 2012 queryMySQL Platform independent MySQL database solution with blob support. Author: Jonathan Karr

Jonathan Karr

Samuel Hurley

Samuel Hurley

This is excellent! I spent all night trying to get Oracle's MySQL Connector/J working with no luck, and this package took literally 5 minutes to set up!

I also had a problem, like Agustin, with trying to query single-character fields from a database (getTiny). I fortunately did not need to query that particular table for my purposes, so everything is great for me.

5
08 May 2012 queryMySQL Platform independent MySQL database solution with blob support. Author: Jonathan Karr

Jonathan Karr

Jonathan Karr

Jonathan Karr

Hi Agustin,

I can try to help. Can you provide more information about the problem? An example query would be helpful.

Best.
- Jonathan

Comment only
08 May 2012 queryMySQL Platform independent MySQL database solution with blob support. Author: Jonathan Karr

Jonathan Karr

Agustin

Agustin

Hi Jonathan,

I had a problem trying to import data from a table. The data is type number with a single character. The problem is with the method getTiny for com.mysql.jdbc.JDBC4ResultSet

Comment only
08 May 2012 queryMySQL Platform independent MySQL database solution with blob support. Author: Jonathan Karr

Jonathan Karr

Agustin

Agustin

5
27 Apr 2012 queryMySQL Platform independent MySQL database solution with blob support. Author: Jonathan Karr

Jonathan Karr

Joe Kuehl

Joe Kuehl

Jonathan or whom ever, I am very new to mysql and working with databases. Can anyone please provide an alternative example of querymysql which accesses some public data base? It would be a great benefit to me. Thank you

Comment only
18 Apr 2012 XMLTestRunDisplay JUnit-style XML logger for MATLAB xunit framework Author: Jonathan Karr

Jonathan Karr

Patrick Cloke

Patrick Cloke

4
06 Mar 2012 queryMySQL Platform independent MySQL database solution with blob support. Author: Jonathan Karr

Jonathan Karr

Jonathan Karr

Jonathan Karr

The library requires MATLAB R2009B (7.11) or newer. MATLAB 2008a-2009a can be used if you replace the "~" on lines 379 and 391 of MySQLDatabase.m with "junk". To use the code with yet older versions of MATLAB you would need to restructure the code to not use modern style classes.

Comment only
01 Feb 2012 queryMySQL Platform independent MySQL database solution with blob support. Author: Jonathan Karr

Jonathan Karr

Nicolas

Nicolas

yep, matlab must be at least 7.12

Comment only
24 Jan 2012 queryMySQL Platform independent MySQL database solution with blob support. Author: Jonathan Karr

Jonathan Karr

Florian Koehler

Florian Koehler

An addition to my last comment. I think I know better where the error has to be:
queryMySQl works for me with Matlab 7.13
but not with Matlab 7.05. I think it depends on the import function which is different in Matlab 7.05.
Does anyone know how to use queryMySQL with Matlab 7.05? How does the import ... command look like?
A solution would be great.
Thank you,
Florian

Comment only
23 Jan 2012 queryMySQL Platform independent MySQL database solution with blob support. Author: Jonathan Karr

Jonathan Karr

Florian Koehler

Florian Koehler

Hi Jonathan,
thank you very much for your help. Everything is working now on my pc. Now I want to install this function also on another pc. Unfortunatelly there I have another problem:
When I finally do:
>> import edu.stanford.covert.db.MySQLDatabase;
I get an error:
??? Error using ==> import
Arguments to IMPORT must either end with '.*' or else specify
a fully qualified class name: edu.stanford.covert.db.MySQLDatabase

I did everything in the same way as I did it on the other pc. But somehow this error occurs. It would be great if you could help me once more.

Thank you very much for everything,
cheers,
Florian

Comment only
13 Jan 2012 queryMySQL Platform independent MySQL database solution with blob support. Author: Jonathan Karr

Jonathan Karr

Jonathan Karr

Jonathan Karr

Hi Florian,

I'm glad you were able to get MySQL to work. If you weren't I was going to suggest first making sure you can connect with a program like MySQL workbench (http://www.mysql.com/products/workbench/). It sounded like you might have a permissions or firewall issue.

Best of luck.
- Jonathan

Comment only
13 Jan 2012 queryMySQL Platform independent MySQL database solution with blob support. Author: Jonathan Karr

Jonathan Karr

Florian Koehler

Florian Koehler

Hi Jonathan,
sorry for my last comment! It worked! :-)
When I repeated exactly what I wrote it worked! Yipee!
Thank you very much for your help and for your program!!!
Cheers,
Florian

Comment only
12 Jan 2012 queryMySQL Platform independent MySQL database solution with blob support. Author: Jonathan Karr

Jonathan Karr

Jonathan Karr

Jonathan Karr

Hi Florian,

Its definitely possible to connect to another machine. Just replace the first argument to MySQLDatabase with the IP address or hostname of your server. On Windows you can get a server's ip address by running the command ipconfig. On Linux you can get your IP address by running ifconfig.

Best.
- Jonathan

Comment only
12 Jan 2012 queryMySQL Platform independent MySQL database solution with blob support. Author: Jonathan Karr

Jonathan Karr

Florian Koehler

Florian Koehler

5
12 Jan 2012 queryMySQL Platform independent MySQL database solution with blob support. Author: Jonathan Karr

Jonathan Karr

Florian Koehler

Florian Koehler

Hello,
thank you very much for this very nice program! It's great.

Nevertheless I have a question:
Is it possible (with this program) to connect to a MySQL database which is located on another pc (it's not a special server but a common pc)?
If yes, what do I have to write for the hostname in:
db = MySQLDatabase('???','test_schema','root','rootPasswordBla');

Would be great if you could help me!
Thanks,
Florian

Comment only

Contact us