PHP connect to apache derby - php

$database='comdb';
$hostname='localhost';
$port=1527;
$user='root';
$password='pass';
$DSN = "DRIVER={IBM DB2 ODBC DRIVER};PROTOCOL=TCPIP;"
. "DATABASE=$database;HOSTNAME=$hostname;PORT=$port;"
. "UID=$user;PWD=$password;";
$dbh = new PDO("odbc:$DSN");
i installed the DB2 ODBC driver and apply php_pdo_odbc.dll on php ext
and still i can't connect to derby error appear after i run the script
Failed to connect: SQLSTATE[08001] SQLDriverConnect: -30082 [IBM][CLI Driver] SQL30082N Security processing failed with reason "17" ("UNSUPPORTED FUNCTION"). SQLSTATE=08001
please let me know if there is alternate way to connect to derby database.
i can access the database using SQuirrel SQL Client but i need to connect it using php.
thanks

I don't believe that the DB2 ODBC driver can connect to the Derby Network Server. However, this question has some ideas you could pursue.

Related

Using PDO's odbc to connect to a MSSQL server instance with Windows Authentication

I'm trying to connect to a MSSQL database using PDO with odbc. I'm aware that there's a package SqlSrv (but for some reason that package (.dll) won't load properly). So I found some documentation arguing it's also possible with PDO. In my PHP.ini I've enabled the extension php_pdo_odbc.dll and it loads fine.
My connection string looks like this:
$conn = new PDO(
'odbc:
Driver=SQL Server;
Server=MyServer\MyInstance;
Database=MyDatabaseName;
Trusted Connection=Yes;',
'MyWindowsUserName',
'MyWindowsPassword'
);
I've tried various properties (for example by prepending the domain to the username, switching with the authentication options User Id, UID, Password, PWD and Trusted Connection) but I keep getting the message
SQLSTATE[28000] SQLDriverConnect: 18456 [Microsoft][ODBC SQL Server
Driver][SQL Server]Login failed for user 'MyWindowsUserName'.
Any suggestions on how to connect to the database with my Windows Account? (that's the only way for me to connect to the database)
Try removing the username & password
$conn = new PDO(
'odbc:
Driver=SQL Server;
Server=MyServer\MyInstance;
Database=MyDatabaseName;
Trusted Connection=Yes;'
);
I have authenticated by Windows with following PHP statement:
This is my code:
$ Conn = new PDO ("odbc: Driver = {SQL Server}; Server=JAMILI-PC\SQLEXPRESS; null; null");
I am using Windows 2008.
I hope it solves your problem.

How to connect php and MS SQL in LAMP

I am trying to connect php with ms sql server in lamp environment.
$con = new PDO('odbc:Driver=FreeTDS; Server=HOST; Database=TWO; UID=sa; PWD=123456789;');
I go through like 100+ suggestion.Nothing works ,
all i get is a BIG and SAME Error SQLSTATE[IM002] SQLDriverConnect: 0 [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified
Can anyone please give a working example, they might tried already.
If you have freeTDS installed try one of the following connection string it works for me:
$db = new PDO("sqlsrv:Server=YouAddress;Database=YourDatabase", "Username", "Password");
$dbh = new PDO ("dblib:host=$hostname:$port;dbname=$dbname","$username","$pw");//if using dblib

How to connect php and hana?

$driver = "HANADB";
$servername = "sercername";
$schema = "schemaname";
$username = "user";
$password = "XXXX";
$conn=odbc_connect("Driver={HANADB};Server=$servername;Schema=$db_name;",
$username, $password);}
I am using an odbc connection to try and connect to my hana schema. However, when i connect I get the following message
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
I am not really sure as to where I am going wrong.
Did you install HANA clients already? Look here for some reference
If the HANA client is installed, the ODBC drivers are automatically added to your host.
May be you want to use the optional parameter cursor_type = SQL_CUR_USE_ODBC ??
Check: http://php.net/manual/en/function.odbc-connect.php
$conn = odbc_connect("", "", "", SQL_CUR_USE_ODBC);
Make sure you are using the 32bit ODBC Administrator to create your connection.
The 32bit ODBC admin is run from C:\Windows\SysWOW64\odbcad32.exe
The 64bit ODBC admin is run from C:\Windows\System32\odbcad32.exe
The 32 bit driver will show up in the list of available drivers as HDBODBC32.
Follow HANA Academy - Installing the 32bit HANA Client for more detailed explanation
Why not using Server Side JavaScript provided by SAP?
I recommend reading chapter 8 "Writing Server-Side JavaScript Code" of the SAP HANA Developer Guide

MS SQL SERVER, PHP, PDO, ODBC: Login failed for user

I'm trying to connect using a string:
odbc:Driver={SQL Server Native Client 11.0};Server=(localdb)\v11.0;Database=test;uid=sa;password=123321;
Result: SQLSTATE[28000] SQLDriverConnect: 18456 [Microsoft][SQL Server Native Client 11.0][SQL Server]Login failed for user 'sa'.
When I try to connect using Windows ODBC Data Source Administrator the connection is successful.
What the problem might be in?
The network user 'sa' does not have permission to the Microsoft SQL Server.
The best way to provide network users access to Microsoft SQL Server is to create a Windows group (for example EGUSERS) and permit the Windows group Server Access at the Security Logins within Microsoft SQL Server.
Put all network users that need to have access to Microsoft SQL Server to the Windows group (EGUSERS).
Check if you have the right authentication mode set on the MSSQL Server:
https://msdn.microsoft.com/en-us/library/ms188670.aspx
Also you have two ways to connect to MSSQL through PHP/PDO by using the PHP_PDO_ODBC extension which uses the ODBC driver given in the connectionstring or use PHP_PDO_SQLSRV_xx_TS or PHP_PDO_SQLSRV_xx_NTS extension which you can find here (only for 32bit PHP!) https://www.microsoft.com/en-us/download/details.aspx?id=20098 or use the unofficial 64bit here http://robsphp.blogspot.nl/2012/06/unofficial-microsoft-sql-server-driver.html
connection string when using PHP_PDO_SQLSRV_xx_(N)TS extension:
$hostname='127.0.0.1';
$dbname='test';
$username='user';
$password='pw';
$dbDB = new PDO("sqlsrv:Server=$hostname;Database=$dbname", $username, $password);
connection string when using PHP_PDO_ODBC extension:
//use any of these or check exact MSSQL ODBC drivername in "ODBC Data Source Administrator"
$mssqldriver = '{SQL Server}';
$mssqldriver = '{SQL Server Native Client 11.0}';
$mssqldriver = '{ODBC Driver 11 for SQL Server}';
$hostname='127.0.0.1';
$dbname='test';
$username='user';
$password='pw';
$dbDB = new PDO("odbc:Driver=$mssqldriver;Server=$hostname;Database=$dbname", $username, $password);
When testing a simple query which returned 66 records using PHP_PDO_ODBC extension took ~500ms (for all three MSSQL ODBC drivers) but when using the 64bit(!) PHP_PDO_SQLSRV_TS it took ~5000ms. 10 times slower! Have not yet tried 32bit or the NTS variant.
My dev PC is Windows 7 SP1 using WAMPx64 PHP 5.5.12 and I used PHP_PDO_SQLSRV_55_TS

Troubleshooting MSSQL Connection from PHP

I'm trying to connect to an external Sql Server through PHP 5.2.
Using this line:
$con = mssql_connect('123.123.123.123','Username','Password') or die('Could not connect to the server!');
I'm receiving this error:
Warning: mssql_connect() [function.mssql-connect]: Unable to connect
to server: 123.123.123.123 in
/home/file/public_html/structure/index.php on line 4 Could not connect
to the server!
My hosting provider assures me that ports are open for my server to connect to the DB. Looking at my php info, MSSQL Support is enabled, using FreeTDS.
Any ideas why this would be failing, or how I can begin trouble shooting the problem?
i know that there is some security for remote connection to MSSQL.
i had a same issue.
you need to give connection permition for requested ip.
did you try to connect with your personal compter with a MS SQL program.
if you can so you have problem with your cilent (php host)
if you can not so you have problem with mssql server

Categories