Existing db2 database in liberty worksphere app in bluemix - eclipse

I have deployed a Worksphere Liberty project from eclipse to Bluemix. Now I want to connect it with an existing Db2 database. What are the steps to follow?

Check out the example app Java DB Web Starter. It uses a DB2 database in Bluemix.

Does your existing database have a URL which is accessible from the internet? If so, you can directly talk to the database from your Bluemix application.
Class.forName("com.ibm.db2.jcc.DB2Driver");
Connection connection = connection = DriverManager.getConnection("jdbc:db2://localhost:50000/yourdb", "username", "pwd");
Be sure to package the db2 driver jar in your WEB-INF/lib.
If your datasource definition is already defined in a Liberty server.xml config, you can push the entire liberty server pacakge.
If your existing database is behind a company firewall, look at the Secure Gateway to expose the connection securely.

Assuming you need to connect to an existing DB2 database that resides on-premises (outside of Bluemix), you would need to use the Bluemix Cloud Integration service. With it, you can move data or create REST APIs for Bluemix applications to access and use.
https://www.ng.bluemix.net/docs/#services/CloudIntegration/index.html#gettingstartedwithcloudintegation

Related

How to configure sailsjs DB connection with Google Cloud SQL

I'm running a Sails.js application that uses a Google Cloud Postgresql instance on Google App Engine. I'm getting a connection refused error when I deploy the application. This is my sailsjs connection config:
postgresGoogle: {
adapter: 'sails-postgresql',
socketPath: '/cloudsql/' + process.env.INSTANCE_CONNECTION_NAME,
user: 'xxxxx',
password: 'xxxxx',
database: 'postgres'
}
If I add the host, it throws a timeout error. Does anyone know the proper way to configure a sailsjs connection with GCP postresql?
Where exactly is your Sails.js application? Is it on App Engine Flex? I would recommend deploying to App Engine Flex, as described here and then connect to the PostgreSQL from the Flex environment. Otherwise, are you using any of the option steps described in this link for connection?
Solved
As of 16 December 2022...
I finally got Sails.js to work today with GCP SQL. If you follow the tutorials from Google you have either Unix Sockets or TCP options to try -- and sadly neither work with out of the box sails-postgres.
My workaround was to connect via a VPC connector with a dedicated IP address. This way I can connect to Cloud SQL using a regular Postgres connection string, directly to the DB.
https://cloud.google.com/appengine/docs/legacy/standard/python/outbound-ip-addresses
Then I whitelisted the new dedicated IP in Cloud SQL security settings, and forced SSL to require valid SSL certificates.
It may not be best practice for now per Google's docs, but it works.

PHP Connect elastic beanstalk to MongoDB ec2

I have an elastic beanstalk web server set up for my website, and have also created an ec2 server and installed mongodb on it so that I can use it as the database for my website. I know the database works, and I can add documents and access them from ec2. However, I wasn't sure how to connect to the mongodb server through PHP from another site (the one I created with elastic beanstalk).
Thank you for any help. I am pretty new with AWS, so if this is a poor website setup, any help would be appreciated.
Could you try under your instance for the EB> security and groups>click on your database instance and edit the inbound rules. Allow SSH/HTTPS/HTTP from your EB's instance.

How can session cache service data be stored externally?

Cross-posting as advised from DeveloperWorks: https://developer.ibm.com/answers/questions/212469/can-an-application-hosted-outside-bluemix-access-s.html
I am exploring a scenario wherein I have an existing Java application hosted on-premises outside BlueMix. I want to make it horizontally scalable. As part of this change I would like to know if I can provision a BlueMix Session Cache service to store the application's session state externally. The application will continue to be hosted outside BlueMix but use BlueMix Session Cache for session state management.
It is not possible at the moment.
Although a person can setup a Liberty runtime with the right connection information copied from VCAP and runtime variables, and use it to host a web application that use session cache client, this machine is outside Bluemix and won't be trusted by the network. As a result, it won't be able to connect to the session cache within Bluemix.

How to establish connection between db and java code in bluemix

I am making a web application in bluemix and for that, I chose java db web starter as boiler plate. I made html files in eclipse and I want db connectivity. I made a table in database (viz userInformation), but I am not getting that where and what code should be written to establish connection. Please help.
If you're deploying a Liberty application, and using the SQLDB service, the connection information and the db driver jar should be automatically configured in the server.xml and a datasource is created for you. You can access it using JNDI. Take a look at this example:
https://developer.ibm.com/bluemix/2014/02/07/java-db2-10-minutes/
Your other option is to parse the VCAP_SERVICES environment variable and read the connection information out of it. Example: https://github.com/IBM-Bluemix/get-started-java
The Bluemix documentation has a lot information on how to make the connection for each services.
Also, you will need to have some server side java code like a Servlet to make this db connection. You can not connect directly from your client side html code.
https://github.com/IBM-Bluemix/java-db

What is the backend of the mobiledata service of Bluemix?

I analyzing if I use or not the mobiledata of Bluemix to my app, but I could not find what is the DB engine behind its Solution.
Anyone know what is the backend of mobiledata service of Bluemix?
Backend of mobile data service of bluemix is cloudant.For details please refer below link on getting started:
https://www.ibm.com/developerworks/cloud/library/cl-rapiddev-app/
Backend of mobile data service of bluemix uses Cloudant NoSQL Database for Bluemix as datastore.
It actually uses Cloudant behind the scenes. Cloudant is based on CouchDB and adds Lucene Indexes as well.
Basically, you can select any database service available on Bluemix to store your data. It depends on type of application and data to be stored. If you need to store relational data, go for a SQLDB service. If your mobile application need to store JSON data, then you need a NoSQL database service available on Bluemix. Cloudant is a good NoSQL database and most developers use it as a mobile data backend service.