I am trying to connect to our Databricks SQL endpoint using PHP in a Docker container.
I setup my Docker container to download and configure the ODBC driver as specified here: https://docs.databricks.com/integrations/bi/jdbc-odbc-bi.html#install-and-configure-the-odbc-driver-for-linux
My Docker setup is at https://github.com/rlorenzo/databricks_php
However, when it try to connect using ODBC from my PHP test script I get the error:
Warning: odbc_connect(): SQL error: [unixODBC][FreeTDS][SQL Server]Unable to connect to data source, SQL state S1000 in SQLConnect in /test_connection.php on line 14
ODBC connect failed: S1000
When I try to connect using the PDO library I get a different error message:
SQLSTATE[08S01] SQLConnect: 20009 [unixODBC][FreeTDS][SQL Server]Unable to connect: Adaptive Server is unavailable or does not exist
The connection details are correct because I was able to connect to the Databricks SQL endpoint using Datagrip. I can also verify that the ODBC library is properly installed because I can query a Microsoft SQL Server.
I must have the Databricks ODBC Connector misconfigured somehow, but I am clueless. From my view everything matches the documentation.
I have tried contacting Databricks support, but they have been unhelpful so far.
The problem was that the Databricks SQL driver does not yet support ARM, which my laptop and Docker container was building for. See ('01000', "[01000] [unixODBC][Driver Manager]Can't open lib '/opt/simba/spark/lib/64/libsparkodbc_sb64.so' : file not found (0) (SQLDriverConnect)")
I updated my repo at https://github.com/rlorenzo/databricks_php with a working example and forced the container to build an x86 version.
Will update my repo if Databricks ever supports ARM.
Hope this helps someone in the future.
Related
I am trying to connect to a Firebird database using PHP.
This is the simple code that I use to connect to it.
$user = "******";
$password = "******";
$ODBCConnection = odbc_connect("DRIVER={Firebird/InterBase(r) driver};Database=******;Server=******;Port=******", $user, $password);
I have installed the ODBC driver for Firebird from this webpage https://www.firebirdsql.org/en/odbc-driver/. I've managed to add the correct (I believe) string to the DRIVER inside the ODBC Conection, but now I encounter this error:
Warning: odbc_connect(): SQL error: [ODBC Firebird Driver]Unable to connect to data source: library 'gds32.dll' failed to load, SQL state 08004 in SQLConnect
I am running an Apache server using XAMPP on localhost. Everything I wrote is in the index.php file, just trying to connect to the database.
Any help would be greatly appreciated.
This error occurs when you do not have the Firebird client library (fbclient.dll, or gds32.dll which is tried as a fallback) installed on your system (or you have it installed, but it has the wrong bitness).
To install the Firebird client library, use a Firebird server installer of the right bitness* (eg Firebird 3 Windows 64-bit from https://www.firebirdsql.org/en/firebird-3-0/), and install the Client components.
That said, if you're using PHP, it might make sense to use the Firebird PHP driver instead (though this will still need fbclient.dll to be installed).
*: right bitness: If you use a 32-bit PHP, you need the 32-bit client library, if 64-bit, then the 64-bit client library.
Hi i am trying to connect with visual fox pro driver using .dbc file here is the code
$dsn = "Driver={Microsoft Visual FoxPro Driver};SourceType=DBF;SourceDB=C:\DataMnt\WINSIMS.DBC;Exclusive=NO;collate=Machine;NULL=NO;DELETED=NO;BACKGROUNDFETCH=NO;";
$conn = odbc_connect($dsn, "", "");
if (!$conn)
exit("Connection Failed: " .$conn );
i am getting below error please help
Error :-( ! ) Warning: odbc_connect(): SQL error: [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified, SQL state IM002 in SQLConnect in C:\wamp64\www\testfiles\odbc_test.php on line 15
even i have installed the driver and its showing in my odbc drivers list and from there i have added that driver and defined .dbc file location.
but still i am getting this error i have read out all stack overflow posts but did not get success so please help. I have added attachment of driver which i have added.
i am using wamp 64 bit on windows 64 bit system i have tested mysql connector driver and that was working fine. i just have .dbc file is there any need of username and password ? or i can fill them blank.
Thanks in advance !
Update :- Microsoft Visual FoxPro Driver is showing in windows->SysWOW64->odbcad32.exe but not showing in windows->system32->odbcad32.exe
I currently have Foxpro ODBC driver running on Windows 10. It interacts with PHP 5.6 in XAMPP 32 bit. The queries are working. I compared your connection string with mine. It looks fine except the path to sourceDB may need to be separated by double back slashes. I have user DSN instead of system DSN. Here's a screen shoot of my ODBC admin panel.
ODBC admin panel
I cannot access the ODBC Driver. I have a 64 bit Windows 7 System. To connect to a ODBC 5.1 Driver I used C:\Windows\SysWOW64\odbcad32. I created a User DSN with name AJOY. There was no problem with that. Everything worked fine for the past 3 months. But now when I use
odbc_connect()
to connect with the same User DSN name i have a problem. I usually connect by the statement
$conn=odbc_connect("Ajoy","","");
There was no problem with the statement earlier. But now When I run my code it returns like
odbc_connect(): SQL error: [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified, SQL state IM002 in SQLConnect
When I check the Data Sources (ODBC) in control panel, I can see the User DSN that I created but I cannot remove it. When i click remove it throws an error like
The setup routines for the MySQL 5.1 Driver ODBC could not be found. Please re-install the driver
It also returns there is an architecture mismatch between the driver and the application. I tried various steps but still it is not working. How to fix this? Help me please!!
I believe your problem is what odbcad32 you are using. You must use the one in the c:\Windows\System32 for a 64 bit application; not the c:\windows\SysWow64 directory.
There are 2 versions, one for 32 bit and one for 64 bit applications.
In PHP scripts, it looks like this is how you connect to an odbc database:
$connection = odbc_connect("Driver={SQL Server Native Client 10.0};Server=$server;Database=$database;", $user, $password);
The problem I'm having is that I don't know what to use for "Driver=". What I put in there is what was provided for another script I saw. In my script, all I do is try to connect using this line, but I get the following error:
Warning: odbc_connect(): SQL error: [unixODBC][Driver Manager]Data source name not found, and no default driver specified, SQL state IM002 in SQLConnect in /srv/www/htdocs/site/test.php on line 8
From what I can tell, it looks like the driver I specified is incorrect. The database I am trying to connect to is an MSSQL database, and I only plan to query for information from it. Is there a way to list the database drivers I have available on my system? I've never had to install/configure any drivers like this before (I've never done anything like this; all php work I've done in the past has been with MySQL). Also, I don't want to compile other software onto my system (if possible); I would prefer to install all packages from repos.
You should have a file called odbcinst.ini (probably in /etc or /usr/local/etc but you can locate it with the command odbcinst -j). This file defines your ODBC drivers. Each driver is named within the [] in each section.
You might find Linux ODBC useful as it contains a thorough explanation of unixODBC, how it works and how to define data sources.
The question was how to find the list of ODBC drivers available. In the command line run:
odbcinst -q -d
This will list the drivers if you don't know already.
I'm running PHP 5.2.4 with ibm_db2 v1.8.0 on Ubuntu 8.04.1 Server. I am trying to hit an IBM iSeries running OS/400 v5R3 but I'm not sure at all how to actually connect without a DSN. I've looked at http://www.connectionstrings.com/ but none of the DB2 or AS/400 connection strings seem to work. All I end up with is:
[IBM][CLI Driver] SQL1013N The database alias name or database name "" could not be found. SQLSTATE=42705 SQLCODE=-1013
Here is my current DSN string:
DRIVER={iSeries Access ODBC Driver};SYSTEM=192.168.0.20;Uid=user;Pwd=password
I've also tried the 'IBM DB2 ODBC DRIVER' but get the same error as the string above.
Here is what I use within the .NET environment:
Provider=IBMDA400.DataSource.1;Data Source=xxx.xxx.xxx.xxx;Password=xxxxxxxxxx;User ID=xxxxxxxxxx;Initial Catalog=SERVERNAME
You might be missing the "Initial Catalog".
As it turns out, I had to use ODBC as there wasn't an easy way to access DBU from PHP without having to set up DB2-C and pipe everything through there.