I am using Ubuntu, I am trying to connect php to snowflake using ODBC driver, I have added driver information in /etc/odbcinst.ini. Here is the driver information, that I am using
[ODBC Drivers]
SnowflakeDSIIDriver=Installed
[SnowflakeDSIIDriver]
APILevel=1
ConnectFunctions=YYY
Description=Snowflake DSII
Driver=path-to-"libSnowflake.so"
DriverODBCVer=03.52
SQLLevel=1
ErrorMessagesPath=path-to-folder-which-has-error-message-xml-files
I am getting error two erros
The error 1 : SFRestRequestFailed could not be found in the en-US locale. Check that /en-US/SFMessages.xml exists.
The error 2 : REST request to the Snowflake is failing(I got this error by checking corresponding message attached to 'SFRestRequestFailed' in SFMessages.xml).
But I am able to connect Snowflake and fetch data using same access details in windows.
Kindly share your ideas to resolve this issue.
Thank you
ErrorMessagePath is a snowflake configuration. If you use the snowflake odbc package for linux, you will find unixodbc.snowflake.ini or iodbc.snowflake.ini which you can use accordingly depending on which driver manager you are using. ErrorMessagePath should be set in unixodbc.snowflake.ini or iodbc.snowflake.ini and your SIMBAINI env var should be set to point to one of these files.
Related
I've been given access to an Oracle Server via ODBC and tested the connection using Oracle SQL Developer. These are the connection constants I've set in PHP:
define('APP_DB_HOST', '192.168.1.1');
define('APP_DB_PORT', '1521');
define('APP_DB_USER', 'MyUser');
define('APP_DB_PASS', 'MyPass');
define('APP_DB_SID', 'MyDatabaseSID');
define('APP_DB_SCHEMA', 'MyDatabaseSchema');
With ADOdb/ODBC, I should be able to use the below, so that I don't need to involve a tnsnames.ora entry:enter link description here
$dsn = '(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST='.APP_DB_HOST.')(PORT='.APP_DB_PORT.'))(CONNECT_DATA=(SERVICE_NAME='.APP_DB_SID.')));User Id='.APP_DB_USER.';Password='.APP_DB_PASS.';';
$db->PConnect($dsn, APP_DB_USER, APP_DB_PASS, APP_DB_SCHEMA);
I get the ADOdb Warning:
Warning: odbc_connect(): SQL error: [unixODBC][Driver Manager]Data source name not found, and no default driver specified, SQL state IM002 in SQLConnect in [..]/adodb/drivers/adodb-odbc_oracle.inc.php on line 87
Have others done this before, and if so, how so?
Beyond ADOdb, if anybody has a less complicated method of connecting by ODBC to Oracle with PHP7.4+, please do share.
I would also suggest you to move to the OCI8 native driver if you have a bit of time and not too much refactoring to do.
Your server should already have an Oracle client installed (to make the current TNS and ODBC work), so the only thing to do is to install the OCI8 Oracle DDL PHP extension. Just copy it to php/ext/ and load it in your php.ini
In the meantime, you can test if the following code works:
require_once("include/adodb5/adodb.inc.php"); //depends on your adodb folder
$conn = NewADOConnection("oci8");
$conn->connect(APP_DB_HOST, APP_DB_USER, APP_DB_PASS, APP_DB_SID);
For info, you can check if your system admin has already installed the OCI8 extension by looking for the OCI8 section in the PHPINFO :
If that is an option for you, I would strongly recommend to connect using the native oci8 driver, instead of relying on ODBC. Refer to ADOdb documentation for connection examples.
If you're stuck with ODBC, then I believe you need to adjust your DSN to specify the name of the driver you want to use in the connection string, e.g. Oracle in instantclient_19_6
Driver={OdbcDriverName};Server=(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=xxx)(PORT=xxx))(CONNECT_DATA=(SERVICE_NAME=xxx)))
In my opinion it's better to specify the user id and password in the function call, i.e. $db->connect($dsn, $username, $password), but if you must have it in the connection string, you may want to try it with uid=xxx;pwd=xxx instead of User Id=xxx;Password=xxx
As an alternative, you could also create a System DSN in your ODBC configuration, and just refer to it by name, instead of hardcoding the TNS connection string directly in your code.
See also Create a DSN for the function odbc_connect for Oracle.
I have yii2 project and connected to ms sql server. I have added dll files necessary for connection to ms sql server and put them in xampp/php/ext and put them in php.ini. I'm using PHP 7.2
This is the dll files that I installed and set in my php.ini
extension=php_pdo_sqlsrv_71_ts_x64
extension=php_pdo_sqlsrv_71_ts_x86
extension=php_pdo_sqlsrv_72_ts_x64
extension=php_pdo_sqlsrv_72_ts_x86
extension=php_sqlsrv_71_ts_x64
extension=php_sqlsrv_71_ts_x86
extension=php_sqlsrv_72_ts_x64
extension=php_sqlsrv_72_ts_x86
After that I install odbc driver 11. I open yii2's default login page and input random username and password, then I got this error:
The table does not exist: {{%user}}
It's because I haven't executed the first migration yet, so user table has not been created yet. This means yii2 has successfully connected to ms sql server, right?
The problem is, when I tried the migration, I got this error:
Exception 'yii\db\Exception' with message 'could not find driver'
What could be the problem? Any help would be much appreciated.
I have been trying to get MsSQL recognised on my linux based web server which currently has Ubuntu installed on it. I have followed the steps shown on this post but i have not managed to get it to work:
Connect PHP to MSSQL via PDO ODBC
Everytime i run the following command in PHP i simply ohly get mysql as though it only picks up the mysql.so file:
foreach (PDO::getAvailableDrivers() as $driver)
{
echo $driver . '<br />';
}
Does anybody know how i can get it to output the odbc driver also? The reason i ask is because the PHP application i am trying to run has the following code in it which i am trying to get around as it's written for Microsoft Server by the looks of it:
if (extension_loaded('pdo_sqlsrv')) $this->extension = 'pdo_sqlsrv';
else if (extension_loaded('pdo_odbc')) $this->extension = 'pdo_odbc';
If i comment the above code out the pdo statement doesn't connect for the reason i mentioned above due to no odbc driver
I tried to install freetds and configure it but i couldn't get it working as odbc doesn't show in the drivers list;
Reading package lists... Done
Building dependency tree
Reading state information... Done
tdsodbc is already the newest version.
unixodbc is already the newest version.
0 to upgrade, 0 to newly install, 0 to remove and 171 not to upgrade.
anybody got any suggestions on reading from MsSQL with PHP 5.4 on linux (Ubtuntu)?
Ok so i managed to get a stage further. I got the ODBC linux driver working and now i have hit another problem: SQLSTATE[08001] SQLDriverConnect: 0 [unixODBC][FreeTDS][SQL Server]Unable to connect to data source <---does this mean that the port needs to be forwarded or that the username and password i have is incorrect? I assume this means that the driver is ok? when i try a tsql it just seems to time out after 60 seconds
It seems nobody had this problem yet.... With db2_connect I found docs that decrible how to load a default library list (*LIBL) on connection but with PDO nothing!
I'd like to perform statements without specifing always the library name in front of file name. I already created a JOB DESCRIPTION to load the libraries, and when I log in with the PC5250 emulator those library are online.
But if I run a query with PDO without specifying the library name following is returned:
Error executing sth in testGet for AS400 SQLSTATE[42S02]:
Base table or view not found: 0
[IBM][System i Access ODBC Driver][DB2 for i5/OS]SQL0204 -
TESTFILE in WEB type *FILE not found.
(SQLPrepare[0] at ext\pdo_odbc\odbc_driver.c:206)
To use the library list, you will need to make sure your connection attributes specify system naming, and I would avoid setting a current schema.
Without much knowledge of PHP + PDO, the stackoveflow tag wiki gives a good introduction. Check that PDO is configured for proper settings for DB2 for i, not LUW or z. Likewise check db2_connect settings. (Why are you using that, instead of straight ODBC?)
I know it's been awhile since you posted but I came across some info on how to do library lists using the PDO driver... see http://yips.idevcloud.com/wiki/index.php/XMLSERVICE/PHPPDOChangeLog.
So for example you could do something like this:
$options = [
PDO::ATTR_PERSISTENT => true,
PDO::ATTR_AUTOCOMMIT => true,
PDO::I5_ATTR_DBC_SYS_NAMING => true,
PDO::I5_ATTR_DBC_LIBL => "LIB1 LIB2 LIB3",
];
$db = new PDO("ibm:SYSTEM", "user", "password", $options);
Keep in mind this will probably require a recent Zend Server (since Dec 2014). I know the latest stuff is in the new ZS 8.5 but I'm not sure about older releases.
You might also be able to leave off the library list option - in my limited testing this appears to let it use the library list from the job description. I'm not sure about the current library and YMMV but I'd be curious to hear back if it works for you or not.
Also for what it's worth an email address for the official maintainer is listed on http://pecl.php.net/package/PDO_IBM. Questions could also be sent to the WEB400 mailing list (http://lists.midrange.com/mailman/listinfo/web400), I think people who are involved in the development of the pdo_ibm driver are on there as well.
If you're talking about these docs, then that is if you're using PDO_IBM on IBM i. I don't think those settings are supported on any other platform. From your error message, it seems that you are using the IBM i Access ODBC driver through PDO_ODBC. The IBM i Access ODBC driver connects to a QZDASOINIT prestart job running in QUSRSYS subsystem. If you want those jobs to use a different job description, you need to use CHGPJE to change it: CHGPJE SBSD(QUSRSYS) PGM(QSYS/QZDASOINIT) JOBD(MYLIB/MYJOBD). If you're using SSL connections, also change QZDASSINIT jobs. You'll need to end any existing QZDASOINIT/QZDASSINIT jobs and the new pre-start jobs will pick up the new settings. Note that this will affect all ODBC, JDBC, OLEDB, .NET connections for IBM i Access drivers.
You can configure the library list through the DSN as well, by setting the DBQ connection string or DefaultLibraries ODBC.INI setting or setting the "Library List" value under the Server tab from the DSN configuration GUI on Windows.
I have a website that runs in Windows server, and it works perfectly fine. I tried to make a copy in my localhost but I get the error:
Warning: odbc_connect() [function.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:\xampp\htdocs\tdms\webfolders\secured\db_fns.php on line 29
Could not connect to database server
line 29 contains:
function fgsdb_connect()
{
$a=array();
$retvar=0;
$result = odbc_connect('FGS','tdms','tdms358',SQL_CUR_USE_ODBC); //---->line 29
if (!$result) // cannot establish connection to database
throw new Exception('Could not connect to database server');
else // connection to database has been established
return $result;
}
I am really new to odbc. the website is written in php and the database that i use in mySQL. though i figured that the database that it is trying to connect is a microsoft access MDE file. (i checked in the site in windows server.) What should i do? im sorry but i am really
It's likely the shortcut for setting ODBC data sources is pointing to the 32bit data sources instead of 64bit.
Go to control panel -> administrative tools --> select data sources(ODBC) --> then right click on that file --> go to properties --> in the shortcut tab -> change the path from
%windir%\System32\odbcad32.exe
to
%windir%\SysWOW64\odbcad32.exe
and make your connection. the driver for MS Access will work fine now.
If it doesnt work, try to connect to the ODBC with a sentence like this:
$conn = odbc_connect("Driver={Microsoft Access Driver (*.mdb)};Dbq=C:\YourFolder\YourFile.mdb",'Youruser', 'YourPassword');
The last 2 leave then just the the '' if you dont have any user or password
I was getting the same error on PHP 7.0.8 64bit while trying to connect to an Access .mdb.
I had to do two things:
Install the 64bit version of "Microsoft Access Database Engine 2010 Redistributable" (even with Access 2016 installed I was getting your error). You can download the driver from:
https://www.microsoft.com/en-us/download/details.aspx?id=13255
Then, if you go to the ODBC Data Source Administrator, you should notice the 64bit version.
Change the driver string to:
Driver={Microsoft Access Driver (*.mdb, *.accdb)}
Hope it helps other people.