Purpose: In this blog entry I will explain the appropriate steps to setting up the JDBC connectivity for IDS on Mac OS X.
All testing for this document was prepared with the following versions of software:
-Java: 1.5.0_16 or 1.6.0_07
-JCC driver: Versions 3.52.78 or 4.2.51
*Have the JCC drivers.(Informix sqli driver is NOT officially supported on Mac OS X)
*Install the "stores_demo" database by running the following:
This is for testing purposes.
Steps to follow:
You want to find out host, port, database , username and password:
(Its going to be needed for the JDBC URL which is in the form of:
database: The database is the name of the database which you will want to access. For example, if you are using the database that the script "dbaccessdemo" creates, then the "database" name would be "stores_demo".
username: The user name of the user that will be connecting to the database
password: The password of the previously mentioned user
2-Determine the appropriate version of the JCC driver to use. If you have JDK 6, you should use JCC version 4. The file related to this version is "db2jcc4.jar". If you have a previous version of the JDK you should be using JCC version 3. The related file is "db2jcc.jar". A way to determine which JCC version you are using is as follows:
3-Now its time to create a sample app. To see a good few samples see:
To test out your installation, try out the included sample java class, which is just a slightly modified version of the sample found on: http://publib.boulder.ibm.com/infocenter/idshelp/v115/index.jsp?topic=/com.ibm.jccids.doc/com.ibm.db2.luw.apdv.java.doc/doc/cjvjdbas.htm
A few things to consider about the sample:
You must give as a command line input the information to complete the URL. The full URL needed is in the form of:
(to see how to obtain the information needed to fill out the URL, see step 1.)
The sample code already includes the "jdbc:ids" part of the URL, so you must pass the rest of the URL. For example, if the host is 'myhost', the port is '1234', the database is 'test_db', the username is 'informix' and the password is 'mypass', then to run the sample application (with it being named EzJava), you'd run it as follows:
java EzJava '//myhost:1234/test_db:user=informix;password=mypass;'
NOTE: This is supposing that the appropriate jar file is included in the CLASSPATH environment variable. If not, you must include it with the "-cp" flag.
Keep in mind that the query executed by the sample app will probably not work with your db, so change the query accordingly to test it out with a table of your own. For this example, you need to have set up your logging mode to be buffered or to log. Otherwise you'll get an exception when trying to commit your connection. If you want to use the "stores_demo" database, to create it run the "dbaccessdemo -log"
4-Make your own app. If you were able to compile and run the sample app without a problem, congratulations, you are now ready to develop your own app. Enjoy!
Establishing JCC connections with IDS: http://www.ibm.com/developerworks/blogs/page/idsteam?entry=establishing_jcc_connections_in_11
IBM Data Server Driver for JDBC and SQLJ Version 3.52 (This is platform independent) (JCC driver): https://www14.software.ibm.com/webapp/iwm/web/preLogin.do?lang=en_US&source=swg-informixfpd
IDS on Mac (free trial available here): http://www-01.ibm.com/software/data/informix/mac/informix/mac/