How to connect to Bluemix dashDB outside the Bluemix environment - ibm-cloud

I have several tables in dashDB and I want to access them from another server in order to filter out the data and insert it to a database on my own server.
In dashDB, there is a Service Credentials section and I clicked "Add Credentials" and it outputted a json file with service credentials info.
I tried to run a simple PHP to test the connection :
<?php
$servername = "dashdb-entry-....";
$username = "dash....";
$password = "....";
// Create connection
$conn = new mysqli($servername, $username, $password);
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
echo "Connected successfully";
?>
and it fails. The error is as follow:
Connection failed: A connection attempt failed because the
connected party did not properly respond after a period of time,
or established connection failed because connected host has failed to respond.
I checked service status of IBM and it seems that everything is running. Is it possible to access the dashDB outside the Blumix environment?

Yes it is possible to connect to dashDB from outside Bluemix. Here you can find some samples on how to connect to dashDB using several programming languages. Please take a look at the PHP Sample: One first difference I can see is that you are using mysqli while you should use db2_connect as in the sample.

You should be able to connect to the dashdb on bluemix using PHP. I also found the following link that explains this in detail.
http://php.net/manual/en/function.db2-connect.php
You can also use ODBC or JDBC method with proper drivers installed on the client and providing the connection credentials found under the
connect --> connection information
from the left hand side after you log in.
Murali

Related

Unable to fetch data from T24(TAFJ R18) when working with design studio

I faced the below error when importing t24 applications in design studio. The T24 server (TAFJ R18) which I try to connect to is up (jboss is running), but still I face this issue:
Unable to fetch data from T24. Check your connection details and if T24 is up and running.
Subroutine:
Return Code: FAILURE
Response size: 1
Response 1 ->Response Code: EB-SECURITY.VIOLATION,Response Type: NON_FATAL_ERROR,Response Text: Please check your Login Credential and/or access rights,Response Info: 98748ebf-f73d-4e86-8506-950b2fd0b5d2,
Looks like the Username and Password you have provided in the t24-server/config/server.properties is not correct. Make sure you can login to T24 (Browser or Classic) with the T24 User provided in these settings:
#T24 User name used for introspection and deployment (TAFJ)
username=INPUTT
#T24 Encrypted password used for introspection and deployment (TAFJ)
password={encoded}gXhuXZkbBuL09T8WFlRR+w==
Other important settings in this file:
#T24 host name to connect to (IP address or Domain name)
host=localhost
#T24 Web service (TAFJ) port number to connect
ws.port=8080
#Protocol: ftp, sftp or local (TAFC & TAFJ: used for *.b and *.d file transfer)
protocol=ws
#context for web-service
context=axis2
We can check the connectivity and also if anyone restarting the jboss while importing.
We can check the server status is "active" in DS, or we can restart the server connectivity.
And make sure if you are using any VPN to connect the Database and still it is active.

Newbie help - how to connect to AWS Redshift cluster (currently using Aginity)

(I'm afraid I'm probably about to reveal myself as completely unfit for the task at hand!)
I'm trying to setup a Redshift cluster and database to help manage data for a class/group project.
I have a dc2.large cluster running with either default options, or what looked like the most generic in the couple of place I was forced to make entries.
I have downloaded Aginity (Win64) as it is described as being specialized for Redshift. That said, I can't find any instructions for connecting using it. The connection dialog requests the follwoing:
Server: using the endpoint for my cluster (less :57xx at the end).
UserID: the Master username for the database defined for the cluster.
Password: to match the UserID
SSL Mode (Disable, Allow, Prefer, Require): trying various options
Database: as named in cluster setup
Port: as defined in cluster setup
I can't get it to connect ("failed to establish connection") and don't know if I'm entering something wrong in Aginity or if I haven't set up my cluster properly.
Message: Failed to establish a connection to 'abc1234-smtm.crone7m2jcwv.us-east-1.redshift.amazonaws.com'.
Type : Npgsql.NpgsqlException
Source : Npgsql
Trace : at Npgsql.NpgsqlClosedState.Open(NpgsqlConnector context, Int32 timeout)
at Npgsql.NpgsqlConnector.Open()
at Npgsql.NpgsqlConnection.Open()
at Aginity.MPP.Common.BaseDataProvider.get_Connection()
at Aginity.MPP.Common.BaseDataProvider.CreateCommand(String commandText, CommandType commandType, IDataParameter[] commandParams)
at Aginity.MPP.Common.BaseDataProvider.ExecuteReader(String commandText, CommandType commandType, IDataParameter[] commandParams)
--- Inner Exception: ---
......
It seems there is not enough information going into Aginity to authorize connection to my cluster - no account credential are supplied. For UserID, am I meant to enter the ID of a valid user? Can I use the root account? What would the ID look like? I have setup a User with FullAccess to S3 and Redshift, then entered the UserID in this format
arn:aws:iam::600123456789:user/john
along with the matching password, but that hasn't worked either.
The only training/tutorial I have been able to find/do on this is the Intro AWS direct you to, at https://qwiklabs.com/focuses/2366, which uses a web-based client that I can't find outside of the tutorial (pgweb).
Any advice what I am doing wrong, and how to do it right?
Well, I think I got it working - I haven't had a chance to see if I can actually create table yet, but it seems to be connected. I had to allow inbound traffic from outside the VPC, as per the above snapshot.
I'm guessing there's a better way than opening it up to all IP addresses, but I don't know the users' (fellow team members) IPs, and aren't they all subject to change depending on the device they're using to connect?
How does one go about getting inside the VPC to connect that way, presumably more securely?

Failed to connect to SQL Database Premium Plan on Bluemix (Error code SQL1776N)

I develop an application using "Ruby on Rails runtime" and "SQL Database Premium Plan" on Bluemix.
When I restart the application, it cannot connect to SQL Database.
The application was operating normally until yesterday.
How can I solve this problem?
Log Messages
2016-04-22T16:19:37.748+0900[App/0]ERRFailed to connect to [IXXXXXXX] due to: uncaught throw :"Connection failed: [IBM][CLI Driver] SQL1776N The command cannot be issued on an HADR database. Reason code = \"1\". SQLCODE=-1776"
2016-04-22T16:19:37.748+0900[App/0]ERRrake aborted!
2016-04-22T16:19:37.749+0900[App/0]ERR/home/vcap/app/vendor/bundle/ruby/2.2.0/gems/activerecord-4.2.3/lib/active_record/connection_adapters/abstract/connection_pool.rb:263:in `block in connection'
2016-04-22T16:19:37.749+0900[App/0]ERR/home/vcap/app/vendor/bundle/ruby/2.2.0/gems/activerecord-4.2.3/lib/active_record/connection_adapters/abstract/connection_pool.rb:348:in `checkout'
...
This should be a temporary issue, it should start to work again shortly. If the problem persists you could open a support request using one of the following methods:
Use the Support Widget. It is available from the user avatar in the
   upper right corner of the main Bluemix UI.  After opening the support
   widget panel, select Get Help > Get In Touch , select the type of
   assistance you need, and then fill out the support form.
Use the Support Site 'Get Help' form. This form is available on a separate site that is made available for ticket submission when you cannot log into Bluemix and access the Support Widget.  Go to http://ibm.biz/bluemixsupport and fill in the support request form.
Please remember to provide the VCAP_SERVICES environment variable value to the SQL Database team.

Dataworks Forge can't establish connection for sql db service

I tried to establish connection using Dataworks Forge for sql db, I got following error.
Unable to establish a connection using the supplied values.Check that all values are correct and try again. Internal Details: Failed to send the request to the handler: The agent at yp-iis-dataworks-ga-wdc01-2-12-0-0-5-vm5:31531 is not available.; nested exception is: com.ibm.iis.prs.exception.CommunicationException: Failed to send the request to the handler: The agent at yp-iis-dataworks-ga-wdc01-2-12-0-0-5-vm5:31531 is not available.
I input the values based on VCAP_Service, and double checked it. How can I troubleshoot this?
Connection name sqldb1
Host 75.126.155.1xx
Database SQLDB
User user06xxx
Port 50000
Password xxx
Today, I did same thing when I posted this question and could establish connection successfully.
As Nigel mentioned, the dataworks service states when I posted was green. But maybe there were some issues. And they were fixed now.

Google App Engine PHP PDO connection fails 'MySQL server has gone away'

So I've setup two different GAE app projects, in the primary app i've created two Cloud SQL instances. I've granted access to my other app on both SQL instances.
When I attempt a simple PDO connection from the app which does not contain the cloud sql instances (live on GAE) I receive this error: SQLSTATE[HY000] [2006] MySQL server has gone away
here is the PHP connection line as per the GAE docs:
$db = new pdo('mysql:unix_socket=/cloudsql/<app-id>:<sql-instance-name>;dbname=<db-name>', 'root', '');
Connecting via IP from my local GAE SDK instance works as expected.
Any suggestions would be great!
So far I've tried:
increasing the max_allowed_packet size 32000
increasing the long_query_time to 60
increasing the wait_timeout to 60
The google app engine documentation states:
"Google Cloud Platform project called <your-project-id> is connecting to a Cloud SQL instance named <your-instance-name>."
You're probably getting an error because for project id you are using the project Id for your appengine application, not your Cloud SQL project ID.
Try:
$db = new pdo('mysql:unix_socket=/cloudsql/<sql-project-id>:<sql-instance-name>;dbname=<db-name>', 'root', '');
In the Cloud Console's Instance Details, under Properties toward the bottom of the screen, there's a field called Instance connection name. So what worked for me was:
$db = new pdo('mysql:unix_socket=/cloudsql/<instance-connection-name>;dbname=<db-name>', 'root', '');
This happened to me today, the problem for me was the app-id, make sure it includes the whole Google Apps domain. e.g. if your app is testapp, your instance is instancetest and your domain is domain.com the complete statement is:
$db = new pdo('mysql:unix_socket=/cloudsql/domain.com:testapp:instancetest;dbname=testdb', 'root', '');
Hope it helps.