DatabaseLink Example for DB2 and Mathematica

2

1

could someone please point me to good example on how to make a JDBC connection to an IBM DB2 database?

Rick QI

Posted 2014-07-31T07:55:16.977

Reputation: 23

Answers

1

Here's how I did it:

Needs@"JLink`";

AddToClassPath["/opt/ibm/db2/V10.5/java/db2jcc4.jar"];

Needs@"DatabaseLink`";

driver = "com.ibm.db2.jcc.DB2Driver";
connStr = "jdbc:db2://localhost:50000/TEST";

username = "db2inst1";
password = "password";

conn = OpenSQLConnection[JDBC[driver, connStr], 
  "Username" -> username, "Password" -> password];

This is with a more or less plain installation of DB2 Express-C on Lubuntu 14.04.

After installation and before evaluating the above WL, my command line prep was roughly this (db2inst1 is the instance owner user account configured by the DB2 installation):

$ su db2inst1
$ cd
$ sqllib/db2profile
$ db2start
$ db2
db2 => create database test

William

Posted 2014-07-31T07:55:16.977

Reputation: 1 093

it's ok, thanks your help. – Rick QI – 2014-08-08T06:45:55.150

@RickQI, glad to be able to help! If this post answered your question to your satisfaction, feel free to click the check mark next to the post to mark it as "accepted". If it didn't, definitely feel free to (a) comment on things specific to this answer here or (b) clarify your question further by editing it with clearly marked updates. (It's important to the good functioning of this site that all posts are accurately marked up to represent their actual status.) Thanks, and hope you're enjoying the community! – William – 2014-08-08T14:15:08.903

Sorry , i forget post "accepted". Now it's accepted this queston . it's very useful and clear. – Rick QI – 2014-08-11T06:28:47.890