Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Problem inserting cell array using fastinsert() into mysql database table

206 views
Skip to first unread message

Iqbal Nouyed

unread,
Jan 11, 2011, 7:46:04 AM1/11/11
to
Hi,

I have a mysql database table of the following schema,

CREATE TABLE IF NOT EXISTS `feresys`.`faces` (
`face_id` INT(11) NOT NULL AUTO_INCREMENT ,
`local_hist` INT(11) NULL DEFAULT NULL ,
`user_id` VARCHAR(45) NOT NULL ,
PRIMARY KEY (`face_id`) ,
UNIQUE INDEX `user_id_UNIQUE` (`user_id` ASC) )
ENGINE = InnoDB
DEFAULT CHARACTER SET = latin1;

I want to insert the following data into the table

id size 1x4 ( eg. '1001')
local_hist size 1x64x256 which is a cell array containing gray_scale histogram of 64 regions of an image, which are all integers 0-255.

I've used the following lines to perform the insertion:

conn = database('dbname', '', '', 'com.mysql.jdbc.Driver', 'jdbc:mysql://localhost:3306/dbname');
extdata = {LH, id};
colnames = {'local_hist', 'user_id'};
tblname = 'tbname';
fastinsert(conn, tblname, colnames, extdata);

But i get the following error message:
?? No method 'setInt' with matching signature found for class
'com.mysql.jdbc.JDBC4PreparedStatement'.

Error in ==> database.fastinsert at 181
StatementObject.setInt(j,tmp) %INTEGER

Can anybody please help me how to solve this problem?

Thanks in advance.

Iqbal Nouyed

unread,
Jan 12, 2011, 2:55:04 AM1/12/11
to
For the record,
we need to convert cell array to matrix to store it into mysql table. Also, we need binary data type (blob) to store matrix and have to convert cell array into single dimensional matrix,since the database binary objects accepts single dimensional array.

So the change is:

exdata = {id, cell2mat(LH)}; % 64x256 to 1x16384

and local_hist BLOB

Ref:
http://www.mathworks.com/support/solutions/en/data/1-1BYF0/index.html?product=DB&solution=1-1BYF0

http://www.mathworks.com/matlabcentral/newsreader/view_thread/286206


"Iqbal Nouyed" <iqbal...@gmail.com> wrote in message <ighjec$2if$1...@fred.mathworks.com>...

0 new messages