Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

panicking on Linux 4.6.0-1.el7.elrepo.x86_64 #99

Open
vishalbhatia09 opened this issue Sep 29, 2017 · 9 comments
Open

panicking on Linux 4.6.0-1.el7.elrepo.x86_64 #99

vishalbhatia09 opened this issue Sep 29, 2017 · 9 comments

Comments

@vishalbhatia09
Copy link

Hi Alex,

I am using your package to connect to teradata, but it is panicking with the following error.

-bash-4.2$ go run bhn_equipment.go
panic: SQLSetEnvUIntPtrAttr: {㠳6} ㈵″㠳4

goroutine 1 [running]:
github.com/alexbrainman/odbc.init.1()
/home/vbhatia/github.com/src/github.com/alexbrainman/odbc/driver.go:72 +0x7f
github.com/alexbrainman/odbc.init()
/home/vbhatia/github.com/src/github.com/alexbrainman/odbc/utf16.go:56 +0x6c
main.init()
/home/vbhatia/github.com/src/bhn/bhn_equipment.go:25 +0x4e
exit status 2

here is my code
package main

import (
"database/sql"
"fmt"
_ "github.com/alexbrainman/odbc"
)

func main() {

    fmt.Println("vim-go")

    db, err := sql.Open("odbc", "DSN=BHN-UAT")
    if err != nil {
            fmt.Println("Could not connect to db:", err)
    }

    err = db.Ping()
    if err != nil {
            fmt.Println("got an error:", err)
    }

    fmt.Println("Connection successful:", db)

}

DSN entry is correct as we are able to connect to teradata using perl.
Please help.

-Vishal

@alexbrainman
Copy link
Owner

panic: SQLSetEnvUIntPtrAttr: {㠳6} ㈵″㠳4

Can you, please, translate this error into English?

Even better - there are 3 calls into api.SQLSetEnvUIntPtrAttr in initDriver function - which of 3 calls fails?

Thank you.

Alex

@vishalbhatia09
Copy link
Author

Hi Alex,

This error is in korean and I dont know how to translate it to english. I have tried using google translator but could not got any help. And I dont know how to change encoding in your package.

Actually all 3 calls to api.SQLSetEnvUIntPtrAttr are panicking. It is panicking on the first call initially(line 35), If we comment out the first call it will panic on 2nd call(line 43) and similarly on 3rd call(line 50). Please help.

Thanks,
Vishal

@alexbrainman
Copy link
Owner

This error is in korean and I dont know how to translate it to english.

I am sorry, but I cannot help you without understand the error message. Does your perl code returns non-English errors too?

Alex

@vishalbhatia09
Copy link
Author

No, I am not getting error in perl script. I am able to connect to terradata db with perl.

@alexbrainman
Copy link
Owner

No, I am not getting error in perl script.

Please, change your perl script so you get an error when you run it. Do you get an error message in Korean?

Alex

@vishalbhatia09
Copy link
Author

vishalbhatia09 commented Oct 4, 2017

Hi Alex,

I am not sure if that is korean, I guess this is because of encoding. Is there a function in your package where I can set encoding.

And I am trying it on Linux 4.6.0-1.el7.elrepo.x86_64. Can you try on this version or do you have a way to confirm that it works for this version to connect to Teradata db. I tried on a VM having Linux 3.10.0-229.el7.x86_64 and your package is working on this VM.

Vishal

@alexbrainman
Copy link
Owner

I am not sure if that is korean, I guess this is because of encoding.

Why would Korean be default setting? I suspect some config file somewhere asks for Korean error messages. Did you try changing the code that it fails to see if error message is not English?

Is there a function in your package where I can set encoding.

The only place where you can specify this is in sql.Open("odbc", "DSN=BHN-UAT"). The second parameter is the connection string that should allow you to control these things. But this is database type and driver specific. So you have to look at your own documentation.

And I am trying it on Linux 4.6.0-1.el7.elrepo.x86_64. Can you try on this version or do you have a way to confirm that it works for this version to connect to Teradata db.

I need both Linux installation and db that you are referring. I have neither.

Alex

@vishalbhatia09
Copy link
Author

Did you try changing the code that it fails to see if error message is not English?

I did not change the perl code, but tried using weigj/go-odbc, it is also giving panic in these weird characters. I commented out all of the code in my program while using your package and found out that it is panicking while initializing only.

I tried adding Charset = UTF-8 in odbc.ini file, but as I mentioned before program is not reaching out to this line to open connection, it is failing while initializing your package.

Thats okay if you dont have the environment. I have a VM with Linux 3.x and tested there and it is initializing properly there.

Vishal

@alexbrainman
Copy link
Owner

I did not change the perl code

Do change the perl code. Maybe change SQL into something that cannot be executed (for example replace SELECT with ZZZZ). And see if it gets proper error message.

but tried using weigj/go-odbc, it is also giving panic in these weird characters

It just shows that it is something configured on your computer,

I commented out all of the code in my program while using your package and found out that it is panicking while initializing only.

Yes. Your error / stacktrace is from

github.com/alexbrainman/odbc.init.1()
/home/vbhatia/github.com/src/github.com/alexbrainman/odbc/driver.go:72 +0x7f

the init function. So I was wrong about "sql.Open" second parameter affect this. It does not. That only leaves whatever config files you have for your ODBC driver. What driver do you use? How did you configure it?

I tried adding Charset = UTF-8 in odbc.ini file, but as I mentioned before program is not reaching out to this line to open connection, it is failing while initializing your package.

No the odbc.ini file is actually might affect things here (there might be other config files too). But I do not know if Charset = UTF-8 is valid line to add to odbc.ini file, You need to read your ODBC driver documentation about that.

I have a VM with Linux 3.x and tested there and it is initializing properly there.

Well if something works for you, I am happy to leave it at that. Maybe you could also compare ODBC drivers installed on both machines. Driver versions and their config files. You might spot the difference that is important.

Alex

@HJTP HJTP mentioned this issue Jul 30, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants