From: Stern on
I am trying to connect to a MySQL database using Mathematica's
databaselink library. I can connect to the test databases provided
with Mathematica (which are HSQL databases), and my MySQL databases
work well on their own, but when I try to connect to the MySQL
database from Mathematica, I get errors.

My connection file looks like this: SQLConnection[JDBC["mysql",
ToFileName["C:\Program Files\MySQL\MySQL Server 5.0\data",
"dbsterntest"]], "Name" -> "MySQL test", "Description" -> "test
connection to MySQL database", "Username" -> "root", "Password" ->
"$Prompt", "RelativePath" -> False, "Version" -> 1.]

I have also tried with the OpenSQLConnection command directly,
OpenSQLConnection[JDBC["mysql","C:\Program Files\MySQL\MySQL Server
5.0\data\dbsterntest"],Username->"root",Password->"$Prompt"]

In both cases, I get the following error: JDBC::error: JDBC error:
Cannot load connection class because of underlying \ exception:
'java.lang.NumberFormatException: For input string: "\Program \
Files\MySQL\MySQL Server 5.0\data\dbsterntest"'.

Help?

From: Chris Williamson on
First your conf file should contain the location of your server such...

SQLConnection[JDBC["mysql", "myhost:3306/testdb"], "Name" -> "MySQL test", "Description" -> "test
connection to MySQL database", "Username" -> "root", "Password" -> "$Prompt", "RelativePath" -> False, "Version" -> 1.]


Next try putting your conf file in
$UserBaseDirectory/DatabaseResources. Then use the name to call
OpenSQLConnection["MySQL test"].

Chris

Stern wrote:
> I am trying to connect to a MySQL database using Mathematica's
> databaselink library. I can connect to the test databases provided
> with Mathematica (which are HSQL databases), and my MySQL databases
> work well on their own, but when I try to connect to the MySQL
> database from Mathematica, I get errors.
>
> My connection file looks like this: SQLConnection[JDBC["mysql",
> ToFileName["C:\Program Files\MySQL\MySQL Server 5.0\data",
> "dbsterntest"]], "Name" -> "MySQL test", "Description" -> "test
> connection to MySQL database", "Username" -> "root", "Password" ->
> "$Prompt", "RelativePath" -> False, "Version" -> 1.]
>
> I have also tried with the OpenSQLConnection command directly,
> OpenSQLConnection[JDBC["mysql","C:\Program Files\MySQL\MySQL Server
> 5.0\data\dbsterntest"],Username->"root",Password->"$Prompt"]
>
> In both cases, I get the following error: JDBC::error: JDBC error:
> Cannot load connection class because of underlying \ exception:
> 'java.lang.NumberFormatException: For input string: "\Program \
> Files\MySQL\MySQL Server 5.0\data\dbsterntest"'.
>
> Help?
>
>

From: Stern on
Interesting. I think I am getting closer, but not quite there yet.

The connection file now reads
SQLConnection[JDBC["mysql", "localhost:3306/dbsterntest"],
"Name" -> "MySQL test2", "Description" ->
"test connection to dbsterntest MySQL database", "Username" -> "root",
"Password" -> "$Prompt", "RelativePath" -> False, "Version" -> 1.]

The location is $UserBaseDirectory/DatabaseResources, as it was before.


Two problems:

1. OpenSQLConnection creates a continuous stream of errors.

Syntax::"stresc : "Unknown string escape \P. More...
Syntax::"stresc : "Unknown string escape \M. More...
Syntax::"stresc : "Unknown string escape \M. More...
Syntax::"stresc : "Unknown string escape \d. More...

2. JDBC::error: JDBC error: Communication failure during handshake. Is there a \
server running on localhost:3306?

There is a server running on localhost:3306; I have no trouble
connecting to it from dedicated MySQL client software.

More help?

Thank you in advance.

Michael Stern

On 1/23/07, Chris Williamson <chrisw(a)wolfram.com> wrote:
> First your conf file should contain the location of your server such...
>
> SQLConnection[JDBC["mysql", "myhost:3306/testdb"], "Name" -> "MySQL test", "Description" -> "test
> connection to MySQL database", "Username" -> "root", "Password" -> "$Prompt", "RelativePath" -> False, "Version" -> 1.]
>
>
> Next try putting your conf file in
> $UserBaseDirectory/DatabaseResources. Then use the name to call
> OpenSQLConnection["MySQL test"].
>
> Chris
>
> Stern wrote:
> > I am trying to connect to a MySQL database using Mathematica's
> > databaselink library. I can connect to the test databases provided
> > with Mathematica (which are HSQL databases), and my MySQL databases
> > work well on their own, but when I try to connect to the MySQL
> > database from Mathematica, I get errors.
> >
> > My connection file looks like this: SQLConnection[JDBC["mysql",
> > ToFileName["C:\Program Files\MySQL\MySQL Server 5.0\data",
> > "dbsterntest"]], "Name" -> "MySQL test", "Description" -> "test
> > connection to MySQL database", "Username" -> "root", "Password" ->
> > "$Prompt", "RelativePath" -> False, "Version" -> 1.]
> >
> > I have also tried with the OpenSQLConnection command directly,
> > OpenSQLConnection[JDBC["mysql","C:\Program Files\MySQL\MySQL Server
> > 5.0\data\dbsterntest"],Username->"root",Password->"$Prompt"]
> >
> > In both cases, I get the following error: JDBC::error: JDBC error:
> > Cannot load connection class because of underlying \ exception:
> > 'java.lang.NumberFormatException: For input string: "\Program \
> > Files\MySQL\MySQL Server 5.0\data\dbsterntest"'.
> >
> > Help?
> >
> >
>

From: Chris Williamson on
I am not certain what the first error is...

As to the second, what is version of the mysql driver are you using?
Look in c:\\program files\\wolfram
research\\mathematica\\5.2\\AddOns\\Applications\\DatabaseLink\\Java.
(5.2 if you are using Mathematica 5.2, 5.1 if you are using Mathematica 5.1)

Chris

Stern wrote:
> Interesting. I think I am getting closer, but not quite there yet.
>
> The connection file now reads
> SQLConnection[JDBC["mysql", "localhost:3306/dbsterntest"],
> "Name" -> "MySQL test2", "Description" ->
> "test connection to dbsterntest MySQL database", "Username" -> "root",
> "Password" -> "$Prompt", "RelativePath" -> False, "Version" -> 1.]
>
> The location is $UserBaseDirectory/DatabaseResources, as it was before.
>
>
> Two problems:
>
> 1. OpenSQLConnection creates a continuous stream of errors.
>
> Syntax::"stresc : "Unknown string escape \P. More...
> Syntax::"stresc : "Unknown string escape \M. More...
> Syntax::"stresc : "Unknown string escape \M. More...
> Syntax::"stresc : "Unknown string escape \d. More...
>
> 2. JDBC::error: JDBC error: Communication failure during handshake. Is
> there a \
> server running on localhost:3306?
>
> There is a server running on localhost:3306; I have no trouble
> connecting to it from dedicated MySQL client software.
>
> More help?
>
> Thank you in advance.
>
> Michael Stern
>
> On 1/23/07, Chris Williamson <chrisw(a)wolfram.com> wrote:
>> First your conf file should contain the location of your server such...
>>
>> SQLConnection[JDBC["mysql", "myhost:3306/testdb"], "Name" -> "MySQL
>> test", "Description" -> "test
>> connection to MySQL database", "Username" -> "root", "Password" ->
>> "$Prompt", "RelativePath" -> False, "Version" -> 1.]
>>
>>
>> Next try putting your conf file in
>> $UserBaseDirectory/DatabaseResources. Then use the name to call
>> OpenSQLConnection["MySQL test"].
>>
>> Chris
>>
>> Stern wrote:
>> > I am trying to connect to a MySQL database using Mathematica's
>> > databaselink library. I can connect to the test databases provided
>> > with Mathematica (which are HSQL databases), and my MySQL databases
>> > work well on their own, but when I try to connect to the MySQL
>> > database from Mathematica, I get errors.
>> >
>> > My connection file looks like this: SQLConnection[JDBC["mysql",
>> > ToFileName["C:\Program Files\MySQL\MySQL Server 5.0\data",
>> > "dbsterntest"]], "Name" -> "MySQL test", "Description" -> "test
>> > connection to MySQL database", "Username" -> "root", "Password" ->
>> > "$Prompt", "RelativePath" -> False, "Version" -> 1.]
>> >
>> > I have also tried with the OpenSQLConnection command directly,
>> > OpenSQLConnection[JDBC["mysql","C:\Program Files\MySQL\MySQL Server
>> > 5.0\data\dbsterntest"],Username->"root",Password->"$Prompt"]
>> >
>> > In both cases, I get the following error: JDBC::error: JDBC error:
>> > Cannot load connection class because of underlying \ exception:
>> > 'java.lang.NumberFormatException: For input string: "\Program \
>> > Files\MySQL\MySQL Server 5.0\data\dbsterntest"'.
>> >
>> > Help?
>> >
>> >
>>
>

From: Stern on
With some prodding from Chris Williamson at Wolfram, I solved this.
Apparently, Mathematica had shipped with version 2.0.14 of the MySQL
driver. I replaced it in with the newest version (5.04), and all is
well.


For others who run into this problem, in my machine, the old driver
could be found at C:\Program Files\Wolfram
Research\Mathematica\5.2\AddOns\Applications\DatabaseLink\Java, and
the new one at http://dev.mysql.com/downloads/connector/j/5.0.html


Thank you,

Michael Stern