Got Questions? Get Answers.
Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
jdbc with matlab

Subject: jdbc with matlab

From: Steven

Date: 11 Oct, 2007 04:23:30

Message: 1 of 5

I want to use a sql server to store matlab data. I
downloaded sql express from microsoft and set it up. I also
set up jdbc to use with sql express and matlab. I went
through the help file and added the classpath ect. I am now
trying to connect to the database and have proved
unsuccesful, I get this message every time I try and
connect: Invalid connection

conn = database('pubs','guest','******',...
'com.microsoft.jdbc.sqlserver.SQLServerDriver',...
'jdbc:sqlserver://localhost:1433');
ping(conn);

I have tried both the querybuilder and the above code and
neither seem to work. I have two questions, Has anyone
successfully implemented jdbc with sql express? And is there
a simple way I be able to test the jdbc to ensure that the
server works properly before I connect to matlab?

Subject: jdbc with matlab

From: tristram.scott@ntlworld.com (Tristram Scott)

Date: 11 Oct, 2007 07:50:22

Message: 2 of 5

Steven <burrguy.athotmailnot@msn.com> wrote:
> I want to use a sql server to store matlab data. I
> downloaded sql express from microsoft and set it up. I also
> set up jdbc to use with sql express and matlab. I went
> through the help file and added the classpath ect. I am now
> trying to connect to the database and have proved
> unsuccesful, I get this message every time I try and
> connect: Invalid connection
>
> conn = database('pubs','guest','******',...
> 'com.microsoft.jdbc.sqlserver.SQLServerDriver',...
> 'jdbc:sqlserver://localhost:1433');
> ping(conn);
>
> I have tried both the querybuilder and the above code and
> neither seem to work. I have two questions, Has anyone
> successfully implemented jdbc with sql express?

I haven't used sql express, but SQLServer has worked for me in the past.

I used code something like this:

dbsrc = 'waltons'; % Datbase source
dbuser = 'bob'; % Database User
dbpass = 'jimbob'; % Database password
dbdrv = 'com.microsoft.jdbc.sqlserver.SQLServerDriver';
dburl = 'jdbc:microsoft:sqlserver://sqlhost:1433;database=waltons';

dbConn = database(dbsrc,dbuser,dbpass,dbdrv,dburl); % Connect

I notice that you don't have the m word in your url. I think it might be
necessary to write it down on this occasion, but you don't have to say it
out loud.

I specified the database in the url because the server ran more than one,
and didn't always do the correct thing.

> And is there
> a simple way I be able to test the jdbc to ensure that the
> server works properly before I connect to matlab?
>

I guess you could follow the Java examples, since it is Java dbc. I recall
looking through the jdbc documentation once and finding it to be quite
good.

--
Dr Tristram J. Scott
Energy Consultant

Subject: jdbc with matlab

From: Karan

Date: 18 Dec, 2007 08:07:28

Message: 3 of 5

I dont think SQL express works with the string

'com.microsoft.jdbc.sqlserver.SQLServerDriver'

Any ideas on how one could modify this string to work for
sql server express?

"Steven " <burrguy.athotmailnot@msn.com> wrote in message
<fek8g2$201$1@fred.mathworks.com>...
> I want to use a sql server to store matlab data. I
> downloaded sql express from microsoft and set it up. I
also
> set up jdbc to use with sql express and matlab. I went
> through the help file and added the classpath ect. I am
now
> trying to connect to the database and have proved
> unsuccesful, I get this message every time I try and
> connect: Invalid connection
>
> conn = database('pubs','guest','******',...
> 'com.microsoft.jdbc.sqlserver.SQLServerDriver',...
> 'jdbc:sqlserver://localhost:1433');
> ping(conn);
>
> I have tried both the querybuilder and the above code and
> neither seem to work. I have two questions, Has anyone
> successfully implemented jdbc with sql express? And is
there
> a simple way I be able to test the jdbc to ensure that the
> server works properly before I connect to matlab?
>
>
>

Subject: jdbc with matlab

From: koen

Date: 27 Nov, 2009 15:15:19

Message: 4 of 5

anyone with a solution for that?
I can't connect to a sql server 2008 database either this way.

Subject: jdbc with matlab

From: Oleg Komarov

Date: 3 Dec, 2009 16:33:20

Message: 5 of 5

"koen " <petrov_vik@hotmail.com> wrote in message <heoqe7$9tn$1@fred.mathworks.com>...
> anyone with a solution for that?
> I can't connect to a sql server 2008 database either this way.
have you tried my submission?
http://www.mathworks.com/matlabcentral/fileexchange/25577-ms-sql-jdbc-connection

Tags for this Thread

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us