Here is a tough one. So I managed to connect to our IBM DB2 database using Windows ODBC DNS method and via the catalogued name. I have the php_pdo_ibm.dll module loaded and it works when connecting doing:
$connection = new PDO('ibm:SomeDB2CataloguedDBName');
The catalogued name (ie: alias) does have the following specified:
db2 update dbm cfg using SSL_CLNT_STASH "C:\somefile.kdb"
db2 update dbm cfg using SSL_CLNT_KEYDB "C:\somefile.kdb"
In the ODBC screen, those parameters are also specified in the Advanced Settings screen:
I know that I can connect using the ODBC connection even if the DB2 DB alias has not been set up as the 3 required SSL parameters are specified there in the db2cli.ini file.
My question is, how can I use the new PDO(.....) in PHP without referencing the DB2 alias nor the ODBC DNS? I expect I would need some sort of special connection string? Thanks.
You can refer to the documentation, which shows an example of connecting via either a DSN alias , or via a connection string with explicit properties.
Both methods should let you make the connection with SSL successfully, assuming your environment is correctly configured.
For connecting with explicitly URL connection string, You need to know the correct Db2 driver name (which may differ from the one shown in the documentation) - your question does not mention which Db2 driver type you are using.
From that documentation page here is a connection URL example:
$db = new PDO(
"ibm:DRIVER={IBM DB2 ODBC DRIVER};DATABASE=testdb;" .
"HOSTNAME=11.22.33.444;PORT=56789;PROTOCOL=TCPIP;UID=testuser;PWD=testpass",
"",
"");
Depending on the Db2 driver name and version, you can add connection properties in the db2dsdriver.cfg XML file (for use with the DSN connection method), or you can place these properties in the connection URL along with any other required properties to make the connection work.
If you are using a Db2 driver that is recent (newer than year 2016) then you can get an SSL connection from CLI applications (like PHP) without needing to use a statically created keystore and without needing to separately deploy the IBM GSK8. This is possible if you have the Db2-instance (or server) certificate in ARM file format and you supply its fully qualified name with the connection attribute SSLServerCertificate="c:/path/to/certificate file"; along with Security=SSL, assuming your target Db2-server environment is already suitably configured. For details, refer to the Db2 Knowledge center for you Db2 server version.
Related
I am new to apache-ignite DB and Dbeaver. I was trying to connect to existing apache-ignite DB from newly downloaded DBeaver IDE.
First you have to choose the type of DB connection (you are given option to choose, like PostGre, Apache-ignite, etc) in my case I choose apache-ignite.
On next step, you have to fill the address of your DB (it is written localhost by default, in my case DB is on remote server, so I filled in IP address of the server) and also 10800 port (as it's standart).
also I filled in the username and password for DB.
After these I pressed Test connection and got this kind of error :
Handshake failed [driverProtocolVer=ClientListenerProtocolVersion [major=2, minor=9, maintenance=0], remoteNodeProtocolVer=ClientListenerProtocolVersion [major=2, minor=8, maintenance=2], err=Unsupported version.]
This error means that apache-ignite driver on your computer and on database claster are different. In my case, my local version 2.9.0 was higher than claster's version 2.8.2.
I had to downgrade my version locally to be able to connect to DB.
Drivers can be downloaded from official website of apache-ignite.
After you download and install drivers, go to your connection in DBeaver and follow steps:
Edit Connection
Edit Driver settings
Add new files of downloaded correct driver version manually, with Add File
Test connection
I'm trying to connect to a Sybase (SQL Anywhere 12) database using PHP's PDO. I spent hours trying to find the correct driver and DSN to use, with NO success AT ALL. Everytime I try to edit a single parameter I always get errors. I tried tens of different combinations of DSN parameters, nothing happens. I'll report here only a few just to give you example of what I'm trying to obtain.
I successfully installed PDO drivers - from php.ini:
PDO drivers dblib, mysql, odbc, pgsql
PDO Driver for FreeTDS/Sybase DB-lib enabled
Flavour freetds
DB params:
The IP for the DB is 192.168.100.234 and both the db instance and db name are GAMMA01. I can't tell you username and password, but let's say: user dba and pwd allright.
I can ping the server from the server where I try to start the connection.
I'm under Linux Debian Squeeze and PHP 5.3.3.
DBLIB:
I'm not able to find the correct DSN to use in order to connect to my Database server.
DSN version 1:
'dblib:host=192.168.100.234;DBN=GAMMA01'
DSN version 2:
'dblib:host=192.168.100.234;DBN=GAMMA01;UID=dba;PWD=allright;Server=GAMMA01;ASTART=No'
DSN version 3:
new PDO('dblib:host=192.168.100.234;dbname=GAMMA01', 'dba', 'allright');
Error I get
SQLSTATE[HY000] Unable to connect: Adaptive Server is unavailable or does not exist (severity 9)
FreeTDS error log (trying with both versions 5.0 and 7.0, no difference):
log.c:190:Starting log file for FreeTDS 0.82
on 2014-04-08 13:40:40 with debug flags 0x4fff.
iconv.c:363:iconv to convert client-side data to the "ANSI_X3.4-1968" character set
iconv.c:516:tds_iconv_info_init: converting "US-ASCII"->"UCS-2LE"
iconv.c:516:tds_iconv_info_init: converting "ISO-8859-1"->"UCS-2LE"
net.c:210:Connecting to 192.168.100.234 port 5200 (TDS version 7.0)
net.c:264:tds_open_socket: connect(2) returned "Operation now in progress"
net.c:299:getsockopt(2) reported: Connection refused
util.c:334:tdserror(0xb9a46eb0, 0xb9b60688, 20009, 115)
dblib.c:7782:dbperror(0xb9b5ff88, 20009, 115)
dblib.c:7835:20009: "Unable to connect: Adaptive Server is unavailable or does not exist"
dblib.c:5627:dbgetuserdata(0xb9b5ff88)
dblib.c:7856:"Unable to connect: Adaptive Server is unavailable or does not exist", client returns 2 (INT_CANCEL)
util.c:368:tdserror: client library returned TDS_INT_CANCEL(2)
util.c:389:tdserror: returning TDS_INT_CANCEL(2)
net.c:310:tds_open_socket() failed
dblib.c:1372:dbclose(0xb9b5ff88)
dblib.c:256:dblib_del_connection(0xb5ceea00, 0xb9b60688)
mem.c:563:tds_free_all_results()
dblib.c:303:dblib_release_tds_ctx(1)
dblib.c:5727:dbfreebuf(0xb9b5ff88)
dblib.c:718:dbloginfree(0xb9b46588)
Using sybase: DSN:
'sybase:host=192.168.100.234;dbname=GAMMA01, dba, allright'
Error:
could not find driver
ODBC:
I'm not able to connect with ODBC drivers. I read the guide here: http://www.sybase.com/files/White_Papers/PHP_SQL_Anywhere.pdf and downloaded the proper .so package here: http://scn.sap.com/docs/DOC-40537 but I can't make PHP recognize the package, load it and use it.
DSN:
'odbc:Driver={Sybase SQL Anywhere 12};NA=192.168.100.234,5200;Uid=dba;Pwd=allright;'
'odbc:Driver={SQL Anywhere 12};NA=192.168.100.234,5200;Uid=dba;Pwd=allright;'
'odbc:DRIVER={Sybase SQL Anywhere 12};SRVR=192.168.100.234;DB=gamma01;UID=dba;PWD=allright;'
'odbc:DRIVER={Sybase SQL Anywhere 12};HOSTNAME=192.168.100.234;DATABASE=gamma01;UID=dba;PWD=allright;PROTOCOL:TCPIP'
Error I get:
SQLSTATE[IM002] SQLDriverConnect: 0 [unixODBC][Driver Manager]Data source name not found, and no default driver specified
Which driver should I use to connect to Sybase db? Which is the correct DSN?
The "Data source name not found and no default driver specified." error means that the DSN or Driver you are specifying cannot be found in the odbc.ini file for your ODBC environment.
You need to make sure that your ODBC environment is setup properly. Typically, this includes a specification for the location and file name of the odbc.ini file.
Upon attempting to connect, the odbc.ini file will be searched to find a matching Data Source Name (DSN)
In your case, you are specifying a "Driver". This is a similar configuration usually found in the odbcinst.ini file; also specified by your ODBC environment.
Another thing to check for is to make sure that the ODBC environment is being found by the running process or owning user for your PHP app.
The key is to figure out what part of the connection sequence is failing. In your case, a successful connection would follow this path:
Application is started
ODBC Connection is attempted
ODBC Environment is searched to find the configuration file (usually odbcinst.ini for "Driver" configurations)
Finds a match for the value specified for "Driver=" in connection string
Connection is attempted using the values configured in the found Driver section along with other options provided in connection string.
The two main things that cause the error you are getting are these:
ODBC Environment is not configured
The DSN or Driver value is not spelled correctly.
I hope this helps.
Tony Hall
I have been scouring the internet for a clear answer to this question and I haven't been able to find one.
We currently have a SQL configuration enabled across packages which stores everything in a database, (dev or prod). It is a tricky process to execute packages, figuring out which configuration the packages are mapped to, and having to change them during testing. My hope is that we can use an environment variable to always use a specific connection string to the specific sql server configuration we want to use based on the machine.
I have seen ways to set up variables with the connection string hard coded as an environment variable with an additional SQL server configuration after to manage this. I have also seen ways to manipulate the connection string using XML and calling that from a variable, or from the package itself.
Both of these solutions work and very well may be viable solutions.
My question that I'm really trying to answer is; Is it possible to develop the entire SQL Server configuration connection through the environment variable? As in combining the connection string with the configuration string so that the one environment variable connects straight to the package configuration? Has anyone tried this? Does it make sense as a solution to the problem?
Yes, we have done this and it works fine. Each package has two configurations: the first is an environment variable and the second is a SQL Server table. The environment variable is the connection string for a database containing a table with all the configurations and it is applied to a connection manager. The SQL Server configuration uses that connection manager to connect to the configuration database and retrieve the individual settings.
Because configurations are applied in order, the connection string for the connection manager is set before the SQL Server configuration tries to use it. In summary:
Create your package
Add a connection manager called "Configuration Database" or whatever
Add a SQL Server configuration to the package, use the "Configuration Database" as the Connection, and choose the settings to be stored in the table
Create an environment variable such as SSIS_PKG_CONF with the connection string to be used for the "Configuration Database" connection manager
Add an environment variable configuration to the package, use the SSIS_PKG_CONF variable, and assign it to the connection string for the "Configuration Database" connection manager
Now when you run the package, the configuration proceeds as follows:
The package processes the environment variable configuration
It assigns the value of the environment variable to the "Configuration Database" connection manager's connection string
The package processes the SQL Server configuration
It uses the "Configuration Database" connection manager to retrieve individual settings from a database table
This has worked well for us because we can change the connection string to point at a different source database for the configuration, without changing anything inside the package or the launcher (i.e. the SQL Agent job or script that runs the packages). There are other ways to do it and some people feel strongly that .dtsConfig files are the better option, but we found it easier to manage environment variables than config files
But in the end managing package configurations is a preference and a lot depends on what is easier in your environment with the tools and practices you already have.
I am having major trouble connecting to my database via ODBC.
The db is local (but I have a mirror on a virtual machine), so I am trying to use the connectionstring:
Dsn=MonetDB;host=TARBELL
where TARBELL is the name of my computer. However, it doesn't connect. BUT, this string does:
Dsn=MonetDB;host=localhost
as does
Dsn=MonetDB
Can anyone explain this? I am at a complete loss.
I have taken down my firewalls (at least until I get this figured out), so that can't be the problem.
I eventually want to change the TARBELL to the mirrored virtual machine running another instance of the database.
Many thanks,
Brett
I can recommend connectionstrings.com for details on the supported syntax across all of the supported ADO.NET providers.
DNS usually resolves TARBALL and localhost differently. You can see with ping:
c:\>ping tarball
Pinging tarball [192.168.1.99] with 32 bytes of data:
^^^^^^^^^^^^
c:\>ping localhost
Pinging tarball [127.0.0.1] with 32 bytes of data:
^^^^^^^^^
The computer name resolves to the external IP, while localhost resolves to the special IP 127.0.0.1 that always points at the local machine. Some installations of MySQL listen on localhost only, so if you specify the computer name, they stop listening.
This behaviour is configured using the bind-address option:
--bind-address=127.0.0.1
Or the equivalent (MySQL also uses DNS to resolve hostnames):
--bind-address=localhost
To make the server listen on all interfaces, specify:
--bind-address=0.0.0.0
On Windows, MySQL reads configuration options from:
WINDIR\my.ini, WINDIR\my.cnf
C:\my.ini, C:\my.cnf
INSTALLDIR\my.ini, INSTALLDIR\my.cnf
See the MySQL manual pages for some more information.
figured i'd post an answer to this here since i found this while searching for a windows monetdb connection string. this is the conn string i'm using and is working for monetdb 5:
DRIVER=MonetDB ODBC Driver;PORT=50000;HOST=<your host>;DATABASE=<your db>;UID=monetdb;PWD=monetdb
I've never seen a "host" parameter for a DSN type connection string. DSN's are either stored with the user, the system or as a file. The way you have referenced your DSN here, it is either stored under your user account or with the system. With a DSN, all the credentials and information about which server and driver to be used are stored in the DSN. If you want control over those parameters, you should consider a DSN-less connection string like so:
"Driver={Mysql}; Server=[server_name];Port=[port_number]; Database=[database_name];UID=[username]; PWD=[password]"
I have an SQL 2005 SSIS package that takes data from an Oracle DB Table, and transfers it to a SQL Server Table.
I have set up an "Oracle Provider for OLE DB" for the Oracle connection and a "SQL Native Client" for SQL Server Connection.
The Oracle and SQL connections will depend on the development and shipping stage, which are:
Local environment
SYS - For integration and System testing
UAT - For user acceptance testing
PRE - Mimics the LIVE system for confidence testing
Live - The live system
In the Connection Manager for Oracle, it expects the following:
Server Name (which, for example can be DEVSERVER)
User Name (which, for example, can be devserver_user)
Password (which, for example, can be devserver_pass)
So, I was wondering how I could parameterise these such that the settings are picked up depending on the server. Ideally this would be a connection string that is stored in the registry (to have commonality with the architecture of other systems in our company).
I have attempted to specify the above settings through Package Configurations. I have also tried specifying the connection string, which would look something like this:
Provider=OraOLEDB.Oracle;Data Source=DEVSERVER;User ID=devserver_user;Password=devserver_pass;PLSQLRSet=1;OLE DB Services = -2;
I have tried this through a registry setting, environment settings, and XML config file. I am mapping these item to the properties on the connection object, but the settings do not seem to hold. I.e. when I open the connection object these settings are not there.
What happens is that when I open the OLE DB source and specify the connection, it fails, because the connection object is not picking up the items in the Package Configurations.
Is there something I am missing, some setting that I have to configure. I guess I'm not sure as to what I'm not seeing anything!
Any help would be appreciated.
Just worked this out this myself.
This really was a case of RTFM! The first paragraph on the MSDN Package Configurations page says it all:
Typically, you create a package set
properties on the package objects
during package development, and then
add the configuration to the package.
Still, I hope this is still of help to other RTFMers!