2

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

Rick QI
  • 23
  • 2

1 Answers1

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
  • 1,103
  • 6
  • 10
  • it's ok, thanks your help. – Rick QI Aug 08 '14 at 06:45
  • @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 Aug 08 '14 at 14:15
  • Sorry , i forget post "accepted". Now it's accepted this queston . it's very useful and clear. – Rick QI Aug 11 '14 at 06:28