Forums > Jitter

MySQL Connector/J for MXJ

June 28, 2007 | 12:46 pm

MySQLJDBC
Download: MySQLJDBC.zip (12kb) http://www.mdhosale.com/media/
MySQLJDBC.zip

MySQL Connector/J for MXJ
The MySQLJDBC MXJ object provides max with a simple interface to the
MySQL Connector/J native Java driver that converts JDBC (Java
Database Connectivity) calls into the network protocol used by the
MySQL database. Being that it is developed in MXJ, it is compatible
with Windows and Mac.

————-
INSTALLATION:
————-
- If you haven’t done so, Install MySQL and make sure it is running
(covering installing, using, and running MySQL is beyond the scope of
this doc. Try a Google search or similar for more details on this.
Some references are provided below)

- Download the MySQL Java Connector class from here:

http://www.mysql.com/products/connector/j/

For developers details on this jar and its use can be found here
(also see the resources below):

http://dev.mysql.com/usingmysql/java/

- place the mysql-connector-java-5.0.6-bin.jar file in your /
Applications/MaxMSP 4.6/Cycling ’74/java/lib/ folder (or whatever
folder you may have defined as a classpath in your
max.java.config.txt file found under /Applications/MaxMSP 4.6/Cycling
’74/java/)

NOTE: do not place it in a subfolder or else it will not work. In
otherwords don’t copy the entire distribution to the classpath, just
the jar file.

- place the MySQLJDBC.class file in your /Applications/MaxMSP 4.6/
Cycling ’74/java/classes/ folder

- Start max.

In the max window you should see something very similar to:
/Applications/MaxMSP 4.6/Cycling ’74/java/lib/mysql-connector-java.jar

The included help file provides some simple examples.

NOTE: The help file assumes you have already created a database
called "maxmsp", with a user name "maxmspuser", and password "mathews".

—————-
ONLINE RESOURCES
—————-

..:For Everyone:..
MySQL Docs

http://dev.mysql.com/doc/

phpMyAdmin (for administration)

http://www.phpmyadmin.net

..:For MXJ Developers:..
Using MySQL With Java:

http://dev.mysql.com/usingmysql/java/

java.sql API

http://java.sun.com/j2se/1.4.2/docs/api/java/sql/package-summary.html

JDBC Basics

http://java.sun.com/docs/books/tutorial/jdbc/basics/index.html

jGuru: JDBC 2.0 Fundamentals
http://java.sun.com/developer/onlineTraining/Database/JDBC20Intro/
JDBC20.html#JDBC202_5


June 30, 2007 | 11:05 am

On 28 Jun 2007, at 13:46, MarkDavid Hosale wrote:

> MySQL Connector/J for MXJ

For completeness, I feel compelled to mention my MXJ JDBC library at

http://www.loadbang.net/space/Software/net.loadbang-SQL

which talks HSQLDB, MySQL and DerbyDB. If Connector/J operates below
the JDBC level, it might be interesting to compare them (performance-
wise at least).

– N.

Nick Rothwell / Cassiel.com Limited
http://www.cassiel.com
http://www.myspace.com/cassieldotcom
http://www.loadbang.net


June 30, 2007 | 11:48 pm

Hello-
For real completeness I guess we should also mention the external
developed by Olaf Matthes:
http://www.akustische-kunst.org/maxmsp/other.html

http://www.publicbeta.cx/maxx/

In theory the code in MySQL Connector/J for MXJ should be easy to
modify to accept any JBDC driver, as long as the appropriate driver
is installed. The modification would require changing two lines of code:

The JDBC driver registration (i.e. for MySQL):
Class.forName("com.mysql.jdbc.Driver");

And the connection string to the database server (i.e. for MySQL):
String url = "jdbc:mysql://"+host+":"+port+"/"+database;
Connection con = DriverManager.getConnection(url, username,
password);

Of course this hasn’t been tested. Also, keep in mind, there may be
some variance in the format of SQL queries from one Database
Management System (DBMS) to another depending on versions, features,
etc.

Keep in mind there are 221 DBMS’s supported by JDBC:

http://developers.sun.com/product/jdbc/drivers

It is understandable that I find it to exhaustive be too exhaustive
to address all of them. In the end I was just building a solution for
connecting to MySQL that worked best for my needs. My primary goal
was to readily encapsulate the features I needed most, and build it
in a generalized way for reuse. I hope that others may find it useful.

If, like MySQL Connector/J for MXJ, the net.loadbang-SQL library is
using JDBC then I am not sure what the real difference in
performance would be? Isn’t it true that both the net.loadbang-SQL
and the MySQL Connector/J for MXJ solutions should address the JDBC
driver at the same level? Really, I would expect some performance
differences on Windows versus OSX since (I believe that) OSX executes
Java at lower level in the OS than Windows. There is also the
question of the MXj binding. This quickly grows into a large discussion.

Anyway, thanks for your feedback, and of course I welcome any other
feedback or comments on this project.

All the best-
MarkDavid

On Jun 30, 2007, at 4:05 AM, Nick Rothwell wrote:

>
> On 28 Jun 2007, at 13:46, MarkDavid Hosale wrote:
>
>> MySQL Connector/J for MXJ
>
> For completeness, I feel compelled to mention my MXJ JDBC library at
>
> http://www.loadbang.net/space/Software/net.loadbang-SQL
>
> which talks HSQLDB, MySQL and DerbyDB. If Connector/J operates
> below the JDBC level, it might be interesting to compare them
> (performance-wise at least).
>
> – N.
>
>
> Nick Rothwell / Cassiel.com Limited
> http://www.cassiel.com
> http://www.myspace.com/cassieldotcom
> http://www.loadbang.net
>
>
>
>
>


July 1, 2007 | 12:24 pm

MarkDavid Hosale wrote:
> Hello-
> For real completeness I guess we should also mention the external
> developed by Olaf Matthes:
> http://www.akustische-kunst.org/maxmsp/other.html

Well, thanks for the kind words, but I have to say that the major work
was done by Bill Orcutt, I just made the Windows port initially. Later
some bug fixes were added, but there still is a problem that crashes Max
after a few hours of use of the external.
In the meantime I rewrote most of the code in order to use just one
child thread which is running all the time (instead of starting a new
thread for each MySQL query as it was done in Bill’s code). This new
version was recently used quite successful for this project
http://www.timelinesonline.com/ (sending about 80 MySQL queries every 15
seconds for about 12 hours). I’ll probably put it online quite soon,
including an UB for Intel Macs if there is some interest.

Olaf


July 1, 2007 | 5:05 pm

> Of course this hasn’t been tested. Also, keep in mind, there may be
> some variance in the format of SQL queries from one Database
> Management System (DBMS) to another depending on versions,
> features, etc.

Indeed. These days I generally implement in Hibernate which protects
me from most of the needless variations.

> If, like MySQL Connector/J for MXJ, the net.loadbang-SQL library is
> using JDBC then I am not sure what the real difference in
> performance would be? Isn’t it true that both the net.loadbang-SQL
> and the MySQL Connector/J for MXJ solutions should address the JDBC
> driver at the same level?

Probably. (Perhaps I misunderstood Connector/J and assumed a lower-
level network connection.)

Nick Rothwell / Cassiel.com Limited
http://www.cassiel.com
http://www.myspace.com/cassieldotcom
http://www.loadbang.net


Viewing 5 posts - 1 through 5 (of 5 total)