I am trying to connect to Microsoft sqlserver from ubuntu using PHP 7, but i am getting this error,
PHP Fatal error: Uncaught Error: Call to undefined function mssql_connect()
FYI: there is no line called ;extension=php_mssql.dll in php.ini to remove the comment.
you are using linux , so you won't find the line
extension=php_mssql.dll
it perhaps be extension=php_mssql.so ,
the php extensions in ubuntu is suffixed by .so
and for connecting to mssql server from php
you have to take a look at PDO MSSQL
Example #1 PDO_DBLIB DSN examples
The following examples show a PDO_DBLIB DSN for connecting to
Microsoft SQL Server and Sybase databases:
mssql:host=localhost;dbname=testdb
sybase:host=localhost;dbname=testdb
dblib:host=localhost;dbname=testdb
This is likely the same as PHP7 can't connect to MySQL
PHP7 no longer supports the mysql interfaces. You will need to start using mysqli or PDO
Related
I am using perl version 5.6.1 (which we are planning to migrate to higher version soon).I am able to connect MS Sql Server 2014 with the below piece of code whereas I am unable to connect MS SQL Server 2019 getting the error posted below
Perl code for db connection testing:
use MSSQL::DBlib;
use MSSQL::Sqllib;
# MS SQL server 2014 the db gets connected using the below stmt where it is throwing error
# for sql server 2019
$dbSession = eval{ (sql_init('xx.xxx.xxx.xx,port no','user','password',"database")};
die "dbconnect.pl: Error at sql_init." if $#;
print "Db connected \n";
Error :
DB-Library error 10013,severity 11: Invalid parameter in DB-Library function reference
DB-Library error 10004,severity 9: Unable to connect :Sql server is unavailable or doesn't exist.SSL security error.
OS error 772:Connection Open (SECDoClientHandshake());
How to resolve this issue in perl version 5.6.1
Forget about MSSQL::Dblib and MSSQL::Sqllib. Microsoft might have dropped backward compatibility for the low-level APIs that these Perl Modules use internally. But I am not an expert here.
One way to do make this possibly work is Perl module DBD::ODBC.
Install a system-wide ODBC data source with the Windows tool "odbcad32.exe". and reference this datasource ("ODBC DSN") by name (e.g. "mydsn") in your Perl Code.
Like this:
use DBI;
$dbh = DBI->connect('dbi:ODBC:DSN=mydsn', 'user', 'password');
Sorry I don't have time to explain in detail how all this needs to be set up.
And the fact that you are using Perl 5.6.1 might indicate that your Windows Platform (including that older version of Microsoft's ODBC codebase) might still be too old for MSSQL 2019.
Besides, ODBC will subtly rewrite your SQL calls in places. So expect some surprises. But this strategy is better than nothing.
I am trying to set up an ODBC connection on RHEL to connect to a redshift cluster. I have installed the latest Redshift ODBC driver, and modified the odbc.ini file to include the necessary details:
[ODBC Data Sources]
Redshift_Connection=Amazon Redshift (x64)
[Redshift_Connection]
Driver=/u01/redshift/lib/64/libamazonredshiftodbc64.so
#Driver=/u01/redshift/lib/32/libamazonredshiftodbc32.so
Description=Amazon Redshift ODBC Driver (64-bit) DSN
Server=****
Port=****
Database=****
locale=en-US
When trying to connect - I get the following error:
{error} STATE=42704, CODE=34772055228426,
MSG=[Amazon][Amazon Redshift] (10) Error occurred while trying to connect:
[SQLState 42704] FATAL: unrecognized configuration parameter "driver_version"
However, 'driver_version' is not a configuration parameter the odbc.ini file. There is additionally an odbcinst.ini file , but that also does not contain it.
I have tried setting a new parameter 'driver_version' and setting it the version of the Redshift ODBC, however that doesn't work either, as well as tried the 32bit driver (that was a hail mary).
Is there any other location that this 'driver_version' parameter could be coming from? Am stuck until I can get this connection working.
The ODBC driver version is 1.4.20, direct from AWS website
Redshift is PostgreSQL 8.0.2 on i686-pc-linux-gnu, compiled by GCC gcc (GCC) 3.4.2 20041017 (Red Hat 3.4.2-6.fc3), Redshift 1.0.22169
It appears that in the com.amazon.redshift.core.v3.ConnectionFactoryImpl.getParametersForStartup there is a parameter that is passed in to load the driver version parameters. This ConnectionFactoryImpl utilizes the com.amazon.redshift.util.DriverInfo class, which pulls the version from this file: redshift_jdbc_driver.properties or sets it by default to the version that you are using. These parameters look to be encoded and passed along, which seem to be the cause of the failure.
You could try to create your own Datasource by setting the properties you want, however that did not work for me.
Edit - For me I am using Spring Boot, I had to remove the #Configuration annotation from the Configuration class, in order to bypass these extra settings.
I have a Sonarqube installation which connects to a SQL Server database. This has been configured and working for close to 12 months.
Today I upgraded Sonar, from an old version (3.x) to the current stable 5.1
I am getting an error like:
jvm 1 | WrapperSimpleApp: Encountered an error running main:
org.sonar.process.MessageException:
Unsupported JDBC driver provider: sqlserver
jvm 1 | org.sonar.process.MessageException: Unsupported JDBC driver provider:
sqlserver
I specified the path to the mssql jar in the conf file, so can't see any reason why this is occurring. Has anyone come across this, or any suggestions?
Support for SQL Server is achieved using the jTDS driver that is bundled with SonarQube, and this can't be changed since SQ 4.5 (see SONAR-5499).
So if your remove the specific entry that you set in the conf/sonar.properties file to specify the path to your JDBC driver, this should solve the problem.
Below is my configuration:
Windows 7 x64 running ActiveState Python 2.7.2.5 (64 bit)
Pyodbc 2.1.8
SQL Anywhere 12 driver 12.00.01.3924.
When I try to connect to my sybase database, I get the below error:
cnxn = pyodbc.connect('DRIVER={'+driver+'};HOST='+host+';DATABASE='+database+';UID='+username+';PWD='+password+';PORT='+port)
ProgrammingError: ('42000', '[42000] [Sybase][ODBC Driver][SQL
Anywhere]Request to start/stop database denied (-75)
(SQLDriverConnect); [42000] [Sybase][ODBC Driver][SQL Anywhere]Request
to start/stop database denied (-75)')
I have tried this with different versions of Pyodbc. I also tried with 32 bit versions of Python and Pyodbc, but was not successful. Googling around gave me nothing concrete, though the problem has been around for some time.
How do I connect seamlessly? I have seen it working some time back on Windows XP, but I do not remember the python and pyodbc versions now. I tried on Windows XP with the same set of above but i get the same error. Please help!!!
I'm landing on this page every time I google for "pyodbc sybase example" and every time I have to re-invent the answer, so let me just post what actually worked.
Tested on py2.7-Linux, py2.7-win and py3.5-win. Since this question is now 3 years old I could only test it on somewhat later version of pyodbc 4.0.17 (from both pypi and conda) and Sybase ASE 15.
It's mostly based on Brian's answer (thanks Bryan!), but to get the "Tadam!" effect you need to pass the port separately:
cnxn = pyodbc.connect(driver=driver, server=host, port=port,
database=database, uid=username, pwd=password)
To get list of drivers, run:
pyodbc.drivers()
The connection string attributes don't match anything I see here or here for Sybase, but I also don't have an instance to test, so take the following with a grain of salt.
Try this syntax to using keywords for the connect method so you don't have to keep up with Sybase-specific attributes:
server = "{0}:{1}".format(host, port)
cnxn = pyodbc.connect(driver=driver, server=server, database=database,
uid=username, pwd=password)
Also note that I'm combining the host and port as formatted in this example.
This is what I did in a Windows 7 machine to connect to sybase database using pyodbc
Install Sybase ASE ODBC driver (Check with your IT whether they have this driver)
Install Python27 32 bit (I installed the Anaconda distribution Anaconda2-5.3.1-Windows-x86.exe)
setup DSN (create new data source using Sybase ASE ODBC driver). Get all the required parameter from appropriate personnel.
Test connect to make sure it connects to sybase database you are looking for.
Here is the sample python code that worked after doing all the above steps.
import pyodbc
syb_con = pyodbc.connect('DSN=yourDSNname', uid='username', pwd='password')
cursor = syb_con.cursor()
cursor.execute("select count(*) from tbl_name)
I am using pentaho data integration 4.1 (Kettle) to build an ETL system. My customer requires connecting to database (MS SQL Server) using window authentication, I knew that Kettle supported it . However when I run my Kettle job, it throws the exception
"I/O Error: SSO Failed: SSPI Not Initialized".
From an article on a forum, I copy library sqljdbc_auth.dll into jre/bin folder. The result is quite good, I can use window authentication to connect to SQL server. But this function is not stable, I mean sometimes it works well, sometimes it throws exception
"I/O Error: SSO Failed: SSPI Not Initialized".
Please tell me how to fix this error.
Thank you.
To connect to SQL Server 2008, I had to install the 'Microsoft JDBC Driver 4.0 for SQL Server' and then add the path to sqljdbc_auth.dll to Spoon.bat in %PENTAHO_DI_JAVA_OPTIONS%. Like this:
set OPT=%PENTAHO_DI_JAVA_OPTIONS% "-Djava.library.path=%LIBSPATH%;C:\PROGRA~1\MICROS~1.0FO\sqljdbc_4.0\enu\auth\x86;C:\PROGRA~1\IBM\SQLLIB\BIN" "-DKETTLE_HOME=%KETTLE_HOME%" "-DKETTLE_REPOSITORY=%KETTLE_REPOSITORY%" "-DKETTLE_USER=%KETTLE_USER%" "-DKETTLE_PASSWORD=%KETTLE_PASSWORD%" "-DKETTLE_PLUGIN_PACKAGES=%KETTLE_PLUGIN_PACKAGES%" "-DKETTLE_LOG_SIZE_LIMIT=%KETTLE_LOG_SIZE_LIMIT%"
Ugly, but that's Java under Windows for you. Works quite reliably now though.
Are you using the JTDS driver? Try that combined with the ntlmauth.dll - that works great for us when running PDI on Windows Server 2003 connecting to various remote sqlserver databases.
We place the DLL in this folder:
libswt\win64
I've had the same issue while using JDBC 1.2.2 with MSSQL 2008. It turns out that there is a bug in the driver, making it randomly crash if you initialize it with more than one connection.
If we used only one initial connection to the DB this error never presented itself.
The issue is fixed in a later versions of JDBC. We currently use 1.3.0 and I/O Error: SSO Failed: SSPI Not Initialized never comes up.