Skip to main content
Inspiring
December 2, 2006
Question

CF and MySQL: Where to start?!

  • December 2, 2006
  • 5 replies
  • 1448 views
I've only used CF with Access dBs. I'd like to start messing around with MySQL. How do I do it?

I'm on Win XP Pro and have the CF MX7 Developer Edition. Can I install a MySQL dB on my machine?
I have a MySQL version of the Ben Forta book files... but don't know how to install them.

HELP! (No rush though) lol

Thanks,

Rick
This topic has been closed for replies.

5 replies

BKBK
Community Expert
Community Expert
December 20, 2006
In the lib directory. A simple search will locate it for you. Oh, and, start your own thread.

Participant
December 19, 2006
i want to run my cf server as a cluster so i installed it as a multiserver, problem is that the dir structure has changed so where do i extract the connectors to?
Participating Frequently
December 15, 2006
Do you have your class path: "C:\CFusionMX\wwwroot\WEB-INF\lib\mysql-connector-java-3.1.10-bin.jar" in your CF Admin ?

>> I don't know where the test dB in MySQL is located, or what it's named. (I'm clueless!)
In JDBC URL "jdbc:mysql://localhost:3306/test" we are specifying localhost. So it will search for the test DB from the same box.
So you need to make sure that you have the DB(test) in the same local machine where you have mySql

Thanks

Sankalan
(www.mindfiresolutions.com)
BKBK
Community Expert
Community Expert
December 17, 2006
Webspinner,
you've come very far, you're almost there.

First things first.

1) Since you intend to use MySQL 5.*, you need to install the latest MySQL JDBC driver. Download it from

http://dev.mysql.com/downloads/connector/j/5.0.html

2) The file has a .TAR.GZ extension, so you have to extract twice -- unzip, untar -- to get to driver file that you need for Coldfusion. It is the file mysql-connector-java-5.0.4-bin.jar.

3) Stop the Coldfusion service. Go to the Coldfusion directory /wwwroot/WEB-INF/lib/ and delete any JAR file whose name begins with mysql-connector-java. That would be the old JDBC driver for MySQL. Don't throw it away just yet, just in case. Cut-and-paste it in your My Documents folder, for example.

4) Copy the new driver file mysql-connector-java-5.0.4-bin.jar into /wwwroot/WEB-INF/lib/.

5) Restart Coldfusion.

6) ... But then you had a question:

> I don't know where the test dB in MySQL is located, or what it's named

Databases in MySQL are just folders. They are located in the directory {MySQL_HOME}\data\, where {MySQL_HOME} stands for the location where you installed MySQL. The default is usually

{MySQL_HOME} = C:\Program Files\MySQL\MySQL Server 5.0.

MySQL comes with an empty folder, hence, empty database, called test in {MySQL_HOME}\data\. Do you have one? If not, not to worry. You will create one in a moment.

7) Now, go one step back. When you were doing the settings for datasource in the Coldfusion Administrator, there were two possibilities you could choose from for the driver field, MySQL(3.1) or Other. The option MySQL(3.1) is old and can give problems with later versions of MySQL. You should have chosen the option Other.

If you didn't, go back to the Coldfusion Adinistrator and redo the settings from scratch, keeping the other settings the same. Also, use the username root and leave the password field empty. Those are MySQL defaults, just to get you started. If during the MySQL installation you had configured a username and password, then enter those values in the Coldfusion Administrator.

8) Did you verify there is a folder named "test" in {MySQL_HOME}\data\? If there is, we're done.

If there isn't, you can create one right away. On your desktop, follow the path (or its equivalent): Start => Programs => MySQL => MySQL Server 5.0 and open the MySQL Command Line Client. You should get "Password:" on the command-line. Press Enter, unless you had configured a password for the MySQL root account. In that case, enter the root password.

You should see "mysql>" on the command line. You can now directly enter SQL statements for the MySQL server. So, at the command-prompt, type

create database test;

and press enter. MySQL should then create a database called test. In fact, while you're at it you can create any database you want, using the same simple SQL statement. Verify from {MySQL_HOME}\data\ that MySQL created them.

9) Verify the datasource settings in the Coldfusion Administrator. Any Joy?



Inspiring
January 10, 2007
Hi BKBK,

ok, I'm back after the holidays.

1. I have a folder named "test" in the right place.
2. I am getting this error in the CF Administrator:
# Connection verification failed for data source: mySQL_dB
[]java.sql.SQLException: Timed out trying to establish connection
The root cause was that: java.sql.SQLException: Timed out trying to establish connection

My settings in the Admin:
JDBC URL ---> jdbc:mysql://localhost:3306/test
Driver Class ---> com.mysql.jdbc.Driver

Boy, I want my MS "Access" back.

What could it be?

Thanks,
Rick


P.S. I downloaded and installed the "mysql-connector-java-5.0.4-bin-g.jar" file here: C:\CFusionMX\wwwroot\WEB-INF\lib
Participating Frequently
December 2, 2006
Yes, you van install the latest MySQL on your machine. And to interact with MySQL DB you need to create datasource. To create the datasources please follow the steps mentioned below.

Download "mysql-connector-java-3.0.17-ga-bin.jar" and paste it inside
C:\CFusionMX7\wwwroot\WEB-INF\lib\mysql-connector-java-3.0.17-ga-bin.jar
Hope your CF installation drive is "C".

Now go to CF administartor > Server Settings > Java and JVM.
In ColdFusion Class Path paste the jar file path "C:\CFusionMX7\wwwroot\WEB-INF\lib\mysql-connector-java-3.0.17-ga-bin.jar" and hit "Submit Changes". Then restart CF.

Now create the MySql data source, give your data source name and select driver as "Other" and provide the following parameters.

JDBC URL: jdbc:mysql://localhost:3306/yourDBName
Driver Class: com.mysql.jdbc.Driver
Driver Name: MySQL Connector J
User Name: YourMySQL User Name
Password: Your Password

For more information, please go through this TechNote.
http://www.adobe.com/cfusion/knowledgebase/index.cfm?id=tn_19170


Thanks

Sankalan
(www.mindfiresolutions.com)
Inspiring
December 14, 2006
OK. I've done the following:

1. downloaded and installed MySQL 5.0.27
2. restarted ColdFusion MX 6
3. Created a datasource in the CF Admin panel named MySQL_test
4. added this as the JDBC URL :jdbc:mysql://localhost:3306/test
5. added this as the Driver Class: com.mysql.jdbc.Driver

I'm getting the following error when I submit the datasource in CF:

Connection verification failed for data source: MySQL_test
[]java.sql.SQLException: Unable to instantiate logger class 'com.mysql.jdbc.log.Log4JLogger', exception in constructor?
The root cause was that: java.sql.SQLException: Unable to instantiate logger class 'com.mysql.jdbc.log.Log4JLogger', exception in constructor?

I have nothing in the Java and JVM Settings, under Class Path. Previously I had tried putting the path to my connector, which is located here: C:\CFusionMX\wwwroot\WEB-INF\lib\mysql-connector-java-3.1.10-bin.jar

Any ideas would be appreciated!

I don't know where the test dB in MySQL is located, or what it's named. (I'm clueless!)

Thanks!

Rick
Inspiring
December 2, 2006
> Can I install a MySQL dB on my machine?
Yep, dev.mysql.com
You can download a windows installer from there. That should get you
started...then dive into the docs...dev.mysql.com/docs/
HTH
--
Tim Carley
www.recfusion.com
info@NOSPAMINGrecfusion.com