alexbrainman / odbc

odbc driver written in go
BSD 3-Clause "New" or "Revised" License
352 stars 140 forks source link

db.Query error: SQLDriverConnect: {H} [unixODBC][{0} [unixODBC][ #139

Open buysteve opened 5 years ago

buysteve commented 5 years ago

I am trying to connect to an Informix DB. I managed to get everything working to the point where isql is working correctly. I am running on CentOS 7 using unixODBC 2.3.1. This is my current odbc.ini settings:

[ODBC Data Sources] Infdrv1=IBM Informix ODBC DRIVER ; ; Define ODBC Database Driver's Below - Driver Configuration Section ; [Infdrv1] Driver=/mah/informix/lib/cli/iclit09b.so Description=IBM INFORMIX ODBC DRIVER Database= Servername= CursorBehavior=0 CLIENT_LOCALE=en_US.819 DB_LOCALE=en_US.819 TRANSLATIONDLL=/mah/informix/lib/esql/igo4a304.so ; ; UNICODE connection Section ; [ODBC] ;uncomment the below line for UNICODE connection ;UNICODE=UTF-16 ; ; Trace file Section ; Trace=0 TraceFile=/tmp/odbctrace.out InstallDir=/mah/informix TRACEDLL=idmrs09a.so

The empty error message is given when this code is executed: rows, err := db.Query("SELECT code,cca_incl,anal_type FROM informix.codes;")

Any ideas? I have tried various locale and unicode settings in the odbc.ini, but to no avail.

Full error message: mah_eppix_takeon: db.Query error: SQLDriverConnect: {H} [unixODBC][ {0} [unixODBC][ panic: runtime error: invalid memory address or nil pointer dereference panic: runtime error: invalid memory address or nil pointer dereference [signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0x4e2bab]

--

alexbrainman commented 5 years ago

Full error message: mah_eppix_takeon: db.Query error: SQLDriverConnect: {H} [unixODBC][ {0} [unixODBC][ panic: runtime error: invalid memory address or nil pointer dereference panic: runtime error: invalid memory address or nil pointer dereference [signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0x4e2bab]

That cannot be full stack trace. Please provide full stack trace and full text of your program that crashed.

Thank you.

Alex

asg1612 commented 4 years ago

Hi, I have a similar issue (or the same).

I use isql and iusql for test the connection obdc. And isql works and iusql throw this error:

root@536a85825851:/tmp/test# iusql -v Infdrv1 [unixODBC][ [unixODBC][ [ISQL]ERROR: Could not SQLDriverConnect

isql can connect with the same odbc.ini:

root@536a85825851:/tmp/test# isql -v Infdrv1 +---------------------------------------+ Connected!
sql-statement
help [tablename]
quit

+---------------------------------------+ SQL>

The difference is (man isql):

isql is a command line tool which allows the user to execute SQL in batch or interactively. It has some interesting options such as an option to generate output wrapped in an HTML table.

   iusql is the same tool with built-in Unicode support.

Can I force in my golang code the support Unicode?

asg1612 commented 4 years ago

I think is this the issue (ANSI) https://github.com/alexbrainman/odbc/issues/88#issuecomment-308952146

alexbrainman commented 4 years ago

Can I force in may golang code the support Unicode?

I doubt.

I think your unixODBC driver or configuration is the problem. I suspect, if you could make iusql command to work, your Go program will just work. See #71 for something similar.

Alex

asg1612 commented 4 years ago

Thanks I try it!

mveverka commented 4 years ago

Try to use the latest version of unixODBC, I used to have unixODBC-2.3.1 and had the same problem, isql worked, iusql did not. After installing unixODBC-2.3.7 iusql works and also the connection from Go works!

asg1612 commented 4 years ago

Hi @mveverka unixODBC-2.3.7 doesn't work. I think the same as @alexbrainman. It is a problem with odbc configuration. Only works with ANSI.

I used the branch for_issue_88 and it woks.

buysteve commented 4 years ago

No sorry I gave up in the end.

On Mon, Apr 27, 2020 at 10:11 AM SayHelloBriggs notifications@github.com wrote:

Hi, have you solved the problem? I am trying to connect to an Informix DB too. I used asp.net core. I get a error the same as your.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/alexbrainman/odbc/issues/139#issuecomment-619811340, or unsubscribe https://github.com/notifications/unsubscribe-auth/AJOT2EAYB6KBVAQCJD5B4V3ROU44RANCNFSM4H7EE53Q .