could someone please point me to good example on how to make a JDBC connection to an IBM DB2 database?
1 Answer
$\begingroup$
$\endgroup$
2
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
-
$\begingroup$ @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! $\endgroup$William– William2014-08-08 14:15:08 +00:00Commented Aug 8, 2014 at 14:15
-
$\begingroup$ Sorry , i forget post "accepted". Now it's accepted this queston . it's very useful and clear. $\endgroup$Rick QI– Rick QI2014-08-11 06:28:47 +00:00Commented Aug 11, 2014 at 6:28