• United States
IBM?
  • Site map
IBM?
  • Marketplace

  • Close
    Search
  • Sign in
    • Sign in
    • Register
  • IBM Navigation
IBM Developer Answers
  • Spaces
    • Blockchain
    • IBM Cloud platform
    • Internet of Things
    • Predictive Analytics
    • Watson
    • See all spaces
  • Tags
  • Users
  • Badges
  • FAQ
  • Help
Close

Name

Community

  • Learn
  • Develop
  • Connect

Discover IBM

  • ConnectMarketplace
  • Products
  • Services
  • Industries
  • Careers
  • Partners
  • Support
10.190.13.195

IBM Cloud platform×

Refine your search by using the following advanced search options.

Criteria Usage
Questions with keyword1 or keyword2 keyword1 keyword2
Questions with a mandatory word, e.g. keyword2 keyword1 +keyword2
Questions excluding a word, e.g. keyword2 keyword1 -keyword2
Questions with keyword(s) and a specific tag keyword1 [tag1]
Questions with keyword(s) and either of two or more specific tags keyword1 [tag1] [tag2]
To search for all posts by a user or all posts with a specific tag, start typing and choose from the suggestion list. Do not use a plus or minus sign with a tag, e.g., +[tag1].
  • Ask a question

Connecting to Dashdb using a data source in the Liberty For Java Profile in Bluemix

120000QKTQ gravatar image
Question by coflynn  (36) | Aug 06, 2015 at 08:54 AM wasdevlibertydashdbibmcloud

My question relates to configuring database connectivity in the Liberty profile when on Bluemix

I would like to configure my server.xml as per https://www-01.ibm.com/support/knowledgecenter/was_beta_liberty/com.ibm.websphere.wlp.nd.multiplatform.doc/ae/twlp_dep_configuring_ds.html in order to connect to a DashDb instance, which is bound to my app

According to this documentation states DashDb is a service that supports automatic configuration https://www.ng.bluemix.net/docs/starters/liberty/index.html#automaticconfigurationofboundservices Which means I can use references to cloud variables in my "datasource" element

My specific question relates to what location can be specified for the "library" element referenced by the datasource?

The sample given in the Bluemix documentation shows how to connect to DashDb by using DriverManager and using the connection details in the VCAP_SERVICES https://www.ng.bluemix.net/docs/services/dashDB/index.html#connect

This suggests that the DashDb driver is on the classpath, in a location accessible to the application where the code runs.

What location is this and can it be referenced in the server.xml in library element, so that I can use a DataSource resource to connect to my DashDb instance.

Thanks in advance

Ralph Earle

People who like this

  1
Comment
10 |3000 characters needed characters left characters exceeded
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster

2 answers

  • Sort: 
270000XYBA gravatar image
Accepted answer

Answer by Ram Vennam (2913) | Aug 06, 2015 at 12:58 PM

When you bind a dashdb service to a Liberty application, the server.xml is automatically configured with dataSource with a jndi name. The database driver jars are also added.

cf files MyAppName app/wlp/usr/servers/defaultServer/server.xml

     <dataSource id='db2-dashDB-a1' jdbcDriverRef='db2-driver' jndiName='jdbc/dashDB-a1' statementCacheSize='30' transactional='true'>
         ...
     </dataSource>
     <jdbcDriver id='db2-driver' libraryRef='db2-library'/>
     <library id='db2-library'>
         <fileset id='db2-fileset' dir='${server.config.dir}/lib' includes='db2jcc4.jar db2jcc_license_cu.jar'/>
     </library>

The database driver jars are here:

cf files MyAppName app/wlp/usr/servers/defaultServer/lib

 db2jcc4.jar                               3.7M
 db2jcc_license_cu.jar                    1015B

Hope this answers your question.

Comment
Ralph Earle

People who like this

  1   Show 4   Share
10 |3000 characters needed characters left characters exceeded
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
120000QKTQ gravatar image coflynn (36)   Aug 07, 2015 at 09:05 AM 0
Share

Thanks Ram. Much appreciated. I have a follow up.

I am reading the "Opting out of service auto-configuration" part of https://www.ng.bluemix.net/docs/starters/liberty/index.html#automaticconfigurationofboundservices

It states "I am providing a server.xml file and I have provided the configuration stanzas for theSQLDB instance because I require a non-standard datasource configuration. I do not want the Liberty buildpack to update my server.xml file, but I still require the Liberty buildpack to ensure that the appropriate supporting software is installed."

I would like to achieve something similar.

Judging from the example you cite below, the Bluemix deployment process copies those JARS to ${server.config.dir}/lib

Is there a way that I can configure the service auto configuration to leave the server.xml as is , but that still copies those JARS to ${server.config.dir}/lib ?

Thanks in advance

120000QKTQ gravatar image coflynn (36) coflynn (36)   Aug 10, 2015 at 09:42 AM 0
Share

Closing this question. Found that what I needed to do was to specify the option of opting out of the config only , as per https://www.ng.bluemix.net/docs/starters/liberty/index.html#automaticconfigurationofboundservices

060000Q5FV gravatar image tmdupard (3)   Oct 08, 2015 at 11:42 AM 0
Share

Hi Ram,

I suppose that the jndi name for dashDb auto-config (jndiName='jdbc/dashDB-a1') is standard and can therefore be used in a JPA persistence.xml config file.

Is that correct?

120000A7FJ gravatar image NickMaynard (31) tmdupard (3)   Oct 07, 2016 at 05:32 AM 0
Share

It appears the JNDI reference is named after the service that's bound to your application. So if you bound a dashDB instance named "MyAmazingDB", you'd get "jdbc/MyAmazingDB".

50HCXA4870 gravatar image

Answer by Shepherd123456 (1) | Jun 21, 2017 at 01:52 AM

Hi Ram,

In my case I have the Dash DB and Liberty in separate spaces, I cannot connect them directly. I have tried packaging the Liberty server along with the war. But after it gets pushed successfully, I cannot figure out the endpoint of my servlet. I have just changed the hostname with the new one. Could you please guide me, whats the issue, or should i do it in any other way.

Comment

People who like this

  0   Share
10 |3000 characters needed characters left characters exceeded
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster

Follow this question

64 people are following this question.

Answers

Answers & comments

Related questions

@Resource annotation not working with Analytics Warehouse connection 5 Answers

Migration from Jetty Google App Engine to Liberty Bluemix 2 Answers

ibmliberty container crashing locally 3 Answers

Packaging a war into a Liberty server 2 Answers

why is FileNotFoundException coming in liberty server when file exists in war file 2 Answers

  • Contact
  • Privacy
  • IBM Developer Terms of use
  • Accessibility
  • Report Abuse
  • Cookie Preferences

Powered by AnswerHub

Authentication check. Please ignore.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • API Connect
  • Analytic Hybrid Cloud Core
  • Application Performance Management
  • Appsecdev
  • BPM
  • Blockchain
  • Business Transaction Intelligence
  • CAPI
  • CAPI SNAP
  • CICS
  • Cloud Analytics
  • Cloud Automation
  • Cloud Object Storage
  • Cloud marketplace
  • Collaboration
  • Content Services (ECM)
  • Continuous Testing
  • Courses
  • Customer Experience Analytics
  • DB2 LUW
  • DataPower
  • Decision Optimization
  • DevOps Services
  • Developers IBM MX
  • Digital Commerce
  • Digital Experience
  • Finance
  • Global Entrepreneur Program
  • Hadoop
  • Hybrid Cloud Core
  • IBM Cloud platform
  • IBM Design
  • IBM Forms Experience Builder
  • IBM Maximo Developer
  • IBM StoredIQ
  • IBM StoredIQ-Cartridges
  • IIDR
  • ITOA
  • InformationServer
  • Integration Bus
  • Internet of Things
  • Kenexa
  • Linux on Power
  • LinuxONE
  • MDM
  • Mainframe
  • Messaging
  • Node.js
  • ODM
  • Open
  • PowerAI
  • PowerVC
  • Predictive Analytics
  • Product Insights
  • PureData for Analytics
  • Push
  • QRadar App Development
  • Run Book Automation
  • Search Insights
  • Security Core
  • Storage
  • Storage Core
  • Streamsdev
  • Supply Chain Business Network
  • Supply Chain Insights
  • Swift
  • UBX Capture
  • Universal Behavior Exchange
  • UrbanCode
  • WASdev
  • WSRR
  • Watson
  • Watson Campaign Automation
  • Watson Content Hub
  • Watson Marketing Insights
  • dW Answers Help
  • dW Premium
  • developerWorks Sandbox
  • developerWorks Team
  • Watson Health
  • More
  • Tags
  • Questions
  • Users
  • Badges