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
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 am converting my application to use MSOLEDBSQL from SQL Server Native Client 11.0
I have changed my connection string from "Driver={SQL Server Native Client 11.0}" to "Provider=MSOLEDBSQL" along with UID,PWD,Server,Database parameters.
But I could not able to connect to the Database and getting "[Microsoft][ODBC Driver Manager] Dialog failed"error message when using SQL_DRIVER_COMPLETE.
IM008 Dialog failed The driver attempted to display its login dialog box and failed.
WindowHandle was a null pointer, and DriverCompletion was not SQL_DRIVER_NO_PROMPT.
Similarly, when used SQL_DRIVER_NOPROMPT, it throws an error "[Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified".
IM002 Data source not found and no default driver specified (DM) The data source name specified in the connection string (InConnectionString) was not found in the system information, and there was no default driver specification.
(DM) ODBC data source and default driver information could not be found in the system information.
The above errors are returned as a result of a call to SQLDriverConnect().
I have downloaded and installed https://learn.microsoft.com/en-us/sql/connect/oledb/download-oledb-driver-for-sql-server?view=sql-server-ver15 and could see the binaries in the system32 folder.
As per MS Docs, registry settings will be done as part of the installation.
All appropriate registry settings for the OLE DB Driver for SQL Server are made as part of the installation process.
Should we do any additional registry configuration or other settings in order to use the MSOLEDBSQL driver ?
When I use the Driver keyword as mentioned above it works for native clients. But if I used "Provider=SQLNCLI11" it fails. Any thoughts on this ?
I suspect the problem is related to loading the driver.
Appreciate it if anyone could help in fixing this issue.
Thanks in Advance.
I had the same error connecting to Azure SQL Server using C++.
Check your connection string.
DRIVER={ODBC Driver 18 for SQL Server};Server=${HOST},${PORT};DATABASE=${DATABASE};UID=${USER};PWD=${PASSWORD};Authentication=SqlPassword;Encrypt=No
I had to turn off Encryption for SqlPassword authentication to work.
Then use the SQL_DRIVER_COMPLETE flag and not SQL_DRIVER_NOPROMPT as advised in the Official Documentation here.
SQLDriverConnect(hDbc, nullptr, connStr, SQL_NTS, nullptr,
0, nullptr, SQL_DRIVER_COMPLETE);
Getting the following error while using mqsicvp to test connectivity to a ODBC data source from IBM Integration Console.
C:\Program Files\IBM\IIB\10.0.0.9>mqsicvp DEFAULTBRK -n MSAPP -v
BIP8299I: User 'db2admin' from security resource name 'odbc::MSAPP' will be used for the connection to datasource 'MSAPP'.
BIP2393E: Database error: ODBC return code '-1' from data source ''MSAPP'' using ODBC driver manager ''odbc32.dll''.
The integration node received an error when processing a database operation. The ODBC return code was '-1'. See the following messages for information obtained from the database about this error.
Use the following messages to determine the cause of the error. Typical problems are an incorrect data source, or table names. Correct either the database or the integration node configuration. Use the mqsicvp command to test connectivity to this database.
BIP2322E: Database error: SQL State ''IM003''; Native Error Code '160'; Error Text ''Specified driver could not be loaded due to system error 1114: A dynamic link library (DLL) initialization routine failed. (IBM DB2 ODBC DRIVER - DB2COPY1, C:\PROGRA~1\IBM\SQLLIB\BIN\DB2CLIO.DLL).''.
The error has the following diagnostic information: SQL State ''IM003'' SQL Native Error Code '160' SQL Error Text ''Specified driver could not be loaded due to system error 1114: A dynamic link library (DLL) initialization routine failed. (IBM DB2 ODBC DRIVER - DB2COPY1, C:\PROGRA~1\IBM\SQLLIB\BIN\DB2CLIO.DLL).''
This message may be accompanied by other messages describing the effect on the integration node itself. Use the reason identified in this message with the accompanying messages to determine the cause of the error. Use the mqsicvp command to test connectivity to this database.
BIP8040E: Unable to connect to the database.
The database cannot be accessed with the specified user Id and password pair.
- Check that the database is running.
- Check that the database has an adequate number of database connections available for use.
- On Windows, check that an ODBC connection has been created.
- On systems that use $ODBCINI, check that the file pointed to by $ODBCINI has been correctly updated.
- On z/OS check the BIPDSNAO member of the component's dataset, and check the DB2 64bit ODBC driver (DSNAO64C) is in the STEPLIB.
- Use mqsisetdbparms to set the password to the correct value and try again.
Software: Windows 10 / IIB 10 / DB2 Server
Steps to reproduce:
Set up ODBC (64-bit) connectivity to a new DB2 database in the form of a System DSN (using the IBM DB2 ODBC Driver version 11.01.2020.1393)
Test that connectivity works from ODBC data source administrator app
Use mqsisetdbparms from IBM Integration Console to set the user and
password
mqsisetdbparms DEFAULTBRK -n odbc::MSAPP -u uid -p pwd
Stop and start the broker
Use mqsicvp to test connectivity
mqsicvp DEFAULTBRK -n MSAPP
The DLL mentioned in the error is at C:\PROGRA~1\IBM\SQLLIB\BIN and this is included within PATH variable already.
I'm not sure why the driver manager odbc32.dll is being used - I presume this is a 32-bit version. However if I try creating a DSN in the 32-bit ODBC data source administrator app, mqsicvp fails with an error saying the architectures do not match.
Suggest you download the fix from IBM for bug IT23069. It is available (indirectly) from this page which eventually redirects to IBM fix central. Worked for me.
The newest developer edition toolkit, 10.0.0.12, seems to have fixed this.
I have tried to follow the instructions in chapter 1 of the HSQLDB doc and started my server like:
java -cp hsqldb-2.2.5/hsqldb/lib/hsqldb.jar org.hsqldb.Server -database.0 file:#pathtodb# -dbname.0 xdb
and I have reason to believe that worked cause it said (among other things):
Database [index=0, id=0, db=file:#pathtodb#, alias=xdb] opened sucessfully in 2463 ms.
However at the next step I try to connect using SqlTool and based on chapter 8 of the documentation I came up with this command to connect:
java -jar hsqldb-2.2.5/hsqldb/lib/sqltool.jar localhost-sa
Which gives the following error:
Failed to get a connection to 'jdbc:hsqldb:hsql://localhost' as user "SA".
Cause: General error: database alias does not exist
while the server says:
[Server#60072ffb]: [Thread[HSQLDB Connection #4ceafb71,5,HSQLDB Connections #60072ffb]]: database alias= does not exist
I am at a loss. Should I specify alias when connecting somehow? What alias would my database have then? The server did not say anything about that...
(also, yes I have copied the sqltool.rc file to my home folder.
Your server has -dbname.0 xdb as the database alias. Therefore the connection URL should include xdb. For example jdbc:hsqldb:hsql://localhost/xdb
The server can serve several databases with different aliases. The URL without alias corresponds to a server command line that does not include the alias setting.
java -jar /hsqldb-2.3.2/hsqldb/lib/sqltool.jar --inlineRc=url=jdbc:hsqldb:localhost:3333/runtime,user=sa
Enter password for sa: as2dbadmin
SqlTool v. 5337.
JDBC Connection established to a HSQL Database Engine v. 2.3.2 database
This error has been hunting me for the last 5 hours.
Together with this stupid error: HSQL Driver not working?
If you want to run your hsqldb on your servlet with Apache Tomcat it is necessary that you CLOSE the runManagerSwing.bat. I know it sounds trivial but even if you create the desired database and you run Eclipse J22 Servlet with Tomcat afterwards, you will get a bunch of errors. So runManagerSwing.bat must be closed.
See my sqltool answer over on the question "How to see all the tables in an HSQLDB database". The critical piece is setting up your sqltool.rc correctly and putting it in the right location.
You can also use the following statement for getting a connection from a files based store. this can be used if you are running the application from Windows.
connection = DriverManager.getConnection("jdbc:hsqldb:file:///c:/hsqldb/mydb", "SA", "");
I have this problem which I am trying to debug for a lot of time.
The setup is like this:
i. The application is a Windows application developed using VS2005, .net 2.0.
ii. I use the Cyrstal reports component Crystal Report Viewer and dynamically display various reports in the same form.
iii. The db is SQLSERVER Express 2005 and situated on a different machine.
When I run the application on the db server, I am able to view the report. However, when I run the application on a different machine which is connected to the above dbServer, I get an error. ( I dont get this error on my dev setup)
Source: CrystakReprotViewer.CS:SendDBLogonForReport() Details:Logon failed.
Details: ADO Error Code: 0x
Source: Microsoft OLE DB Provider for SQL Server
Description: [DBNETLIB][ConnectionOpen (Invalid Instance()).]Invalid connection.
SQL State: 08001
Native Error:
Error in File C:\DOCUME~1\admin\LOCALS~1\Temp\ActionPoints {52820D22-199C-4D46-A76B-70A55D9F54D5}.rpt:
Unable to connect: incorrect log on parameters. at CrystalDecisions.ReportAppServer.Controllers.DatabaseControllerClass.SetTableLocation(ISCRTable CurTable, ISCRTable NewTable)
at CrystalDecisions.CrystalReports.Engine.Table.set_Location(String value)
at Trivalve.UI.Client.Reports.CrystalViewer.CrystalReportViewer.SetDBLogonForReport(ConnectionInfo connectionInfo, ReportDocument reportDocument) in D:\Ramjee\Work\Projects\Trivalve\Trivalve\src\tfssetup\2008\Trivalve_2008\Trivalve\Reports\CrystalViewer\CrystalReportViewer.cs:line 127 rptcontrollers.dll SetTableLocation
For more information, see Help and Support Center at http://go.microsoft.com/fwlink/events.asp.
Thanks,
Ramjee
Use datasource=servername or ip address\instance name if available,port number
Default port number is 1433 or 1434
My problem was solved with this. Posting for the use of others.
If this is a standard installation of SQL Server Express, bear in mind that the only connection method installed by default is shared memory, and is only available on the server -- you would need to enable another connection protocol such as Named pipes or TCP/IP. To turn networking on, Use SQL Server Configuration Manager to enable relevant protocols and start SQL Browser.
It's telling you exactly what's wrong.
Details:Logon failed.
Great, we can't logon.
(Invalid Instance()).]Invalid
connection.
Okay. I bet we have "localhost" as part of the instance name in my connection string. Since I'm no longer on the "localhost", this obviously won't work. Let's try there first. Then perhaps it's the credentials that I'm using to query my database. Usually what I do is create a RO user that can only do selects on my db and use that for CR. If none of these are getting me close, let's try making sure that remote connections are enabled for SQLEXPRESS
Unable to connect: incorrect log on
parameters.
Ok it's definitely a connection issue.