I need to access DB2 database in plain standalone Java project.
I cannot use datasource from container right? Do I need to write JDBC connection?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
You need to have necessary db2 JDBC jars in your program’s compile time, runtime classpath.
If you have native DB2 client installed on target machines, you may use JDBC ODBC Bridge. However, best to stick with pure Java- type4 drivers. (db2jcc.jar, db2jcc_license*.jar etc)
Once the drivers are in classpath, you may use usual JDBC code to start with. Such as:
and so on.
Look at IBM documentation here for better examples and details