Overview
Features
Download
Documentation
Community
Add-Ons & Services

Poco ODBC Connection String

Please post support and help requests here.

Poco ODBC Connection String

Postby electic » 17 May 2007, 08:23

Hi,

I am trying to connect to a MS SQL database and wanted to know what the connection string wtould look like, are these standard connection strings?

electic
 
Posts: 48
Joined: 30 Jan 2007, 20:28

Re: Poco ODBC Connection String

Postby electic » 17 May 2007, 08:24

Something like this:

Driver={SQL Native Client};Server=myServerAddress;Database=myDataBase;Uid=myUsername;Pwd=myPassword;
electic
 
Posts: 48
Joined: 30 Jan 2007, 20:28

Re: Poco ODBC Connection String

Postby alex » 17 May 2007, 13:36

> Hi,
>
> I am trying to connect to a MS SQL database and wanted to know what the connection string wtould look like, are these standard connection strings?

The string you pass to the Session (i.e. SessionFactory), is passed unaltered to the SQLDriverConnect() call, so you can supply the complete connection string of your own or predefine a DSN and supply it as connection string.

Alex
alex
 
Posts: 1104
Joined: 11 Jul 2006, 16:27
Location: United_States

Re: Poco ODBC Connection String

Postby electic » 18 May 2007, 00:38

Hi Alex,

Thanks for the reply. I tried this:

Poco::Data::ODBC::Connector::registerConnector();

try {
dbConnection = new Session("ODBC", "Server=192.168.8.156;Port=1433;UID=sa;PWD=xx");

and the program just exist due to an assertion. Do you have some examples where you are connecting to something other than a sqlite db?

I am using unixodbc and isql works great so I am sure my setup is right, just not quite sure what poco is doing.

%
Assertion violation: _connectors.end() != it [in file "src/SessionFactory.cpp", line 89]
%
Assertion violation: _connectors.end() != it in file "src/SessionFactory.cpp", line 89

Deb
electic
 
Posts: 48
Joined: 30 Jan 2007, 20:28

Re: Re: Poco ODBC Connection String

Postby alex » 18 May 2007, 04:07

You have to register the connector first. Make sure you have this before you try to connect:

Code: Select all

ODBC::Connector::registerConnector();


Exception is thrown because factory does not know about your connector. We plan to have this automatically done for the next version. Unfortunately, at this time, it is a manual thing.

Alex
alex
 
Posts: 1104
Joined: 11 Jul 2006, 16:27
Location: United_States

Re: Re: Re: Poco ODBC Connection String

Postby alex » 18 May 2007, 04:13

> You have to register the connector first. Make sure you have this before you try to connect:

Sorry, I did not see that you have the register line of code (the code is butchered by the formatting). Given that you are registering the connector, at this point I'm not sure what the problem might be.

alex
alex
 
Posts: 1104
Joined: 11 Jul 2006, 16:27
Location: United_States

Re: Re: Poco ODBC Connection String

Postby alex » 18 May 2007, 04:34

> and the program just exist due to an assertion. Do you have some examples where you are connecting to something other than a sqlite db?

Did you try to run the tests for your database? $POCO_BASE/Data/ODBC/testsuite is where the code is.
alex
 
Posts: 1104
Joined: 11 Jul 2006, 16:27
Location: United_States

Re: Re: Poco ODBC Connection String

Postby alex » 18 May 2007, 05:00

> dbConnection = new Session("ODBC", "Server=192.168.8.156;Port=1433;UID=sa;PWD=xx");

Just occurred to me:

If SessionFactory is giving you trouble, you can try following:
Code: Select all

dbConnection = new Session(ODBC::Connector().createSession("Server=192.168.8.156;Port=1433;UID=sa;PWD=xx"));

However, I would also like to drill down to the bottom of the factory problem, so keep me up to date on how things go.

Alex
alex
 
Posts: 1104
Joined: 11 Jul 2006, 16:27
Location: United_States

Re: Poco ODBC Connection String

Postby electic » 20 May 2007, 00:12

Well things got better, but the program just hangs. Not sure why, or is it my connection string or what not. But in the debugger, it never steps pass that line. I will try and step into it and see what it is doing tonight but I am completely lost at this point.

Alex, you probably tested it with SQL Server. If you have any way you can write what connection string you used and your UNIX setup, that would be a huge help. Or if someone else out there has this working, maybe share you setup.
electic
 
Posts: 48
Joined: 30 Jan 2007, 20:28

Re: Re: Poco ODBC Connection String

Postby alex » 20 May 2007, 16:28

> Well things got better, but the program just hangs. Not sure why, or is it my connection string or what not. But in the debugger, it never steps pass that line. I will try and step into it and see what it is doing tonight but I am completely lost at this point.

I'd say your best bet is to set ODBC debugging/tracing. That will tell you exactly what your ODBC calls are, which one fails and why. Try to put following in /etc/odbc.ini (or wherewer your odbc.ini might be):

Code: Select all

[ODBC]
Trace = 1
TraceFile = /tmp/odbctrace.log
Debug = 1
DebugFile = /tmp/odbcdebug.log


> Alex, you probably tested it with SQL Server. If you have any way you can write what connection string you used and your UNIX setup, that would be a huge help. Or if someone else out there has this working, maybe share you setup.

Unfortunately, I did not. However, this does not mean your code should not work. Trying to reproduce your problem with SessionFactory, I have tried connection with PostgreSQL from Linux yesterday, using SessionFactory and passing both Connector::KEY and plain "ODBC" string and it connects without a problem.

Here are my windows DNS settings for SQLServer:

Code: Select all

[HKEY_LOCAL_MACHINESOFTWAREWow6432NodeODBCODBC.INIPocoDataSQLServerTest]
"Driver"="C:\WINDOWS\SysWOW64\sqlncli.dll"
"Server"="localhost"
"Database"="test"
"Language"="us_english"
"LastUser"="test"


I'll try to connect to SQLServer from Linux using FreeTDS (is that what you are using?). For the next release, I'll do my best to provide DSN-less connection strings with settings that work.

Alex
alex
 
Posts: 1104
Joined: 11 Jul 2006, 16:27
Location: United_States

Next

Return to Support

Who is online

Users browsing this forum: No registered users and 1 guest