Unable to connect to sql server with odbc on QT ubuntu - c++

I'm trying to connect to locahost sql server but all the time I receive error:
[Microsoft][ODBC Driver 17 for SQL Server][SQL Server]Loggin faield for user 'user'. QODBC3: Unable to connect;
I'm using Qt 5.4 on ubuntu.
Connection string:
QString connectionString = QString(("DRIVER=/opt/microsoft/msodbcsql17/lib64/libmsodbcsql-17.7.so.2.1;SERVER=localhost;DATABASE=FightClubDB;UID=kudryavii;PWD=Pass;"));
QSqlDatabase db{QSqlDatabase::addDatabase("QODBC", connectionId)};
db.setDatabaseName(connectionString);
return connectionId;

If you installed mssql-server via this article: https://learn.microsoft.com/en-us/sql/linux/quickstart-install-connect-ubuntu?view=sql-server-ver15
then to connect to sql server you will have to use "SA" username not you account name...

Related

Issue with my odbc connector 8.0 that connects to mysql8 in centos7

I tried to connect using isql command (Both are AWS EC2)
# isql -v WebDB
[S1000][unixODBC][MySQL][ODBC 8.0(w) Driver]Can't connect to MySQL server on 'ip:3306' (110)
[ISQL]ERROR: Could not SQLConnect
But I can able connect manually
~**]# mysql -h ip -u useranme -p $pwd**
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MySQL connection id is 304
Server version: 8.0.29 MySQL Community Server - GPL
Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
MySQL [(none)]>
I tried to restart opensips that need to connect remote mysql8
/usr/local/sbin/opensips[2905]: ERROR:db_mysql:db_mysql_connect: driver error(2003): Can't connect to MySQL server on 'ip'
/usr/local/sbin/opensips[2905]: ERROR:db_mysql:db_mysql_new_connection: initial connect failed
/usr/local/sbin/opensips[2905]: ERROR:core:db_do_init: could not add connection to the pool
[2905]: ERROR:dialog:init_dlg_db: unable to connect to the database
/usr/local/sbin/opensips[2905]: ERROR:dialog:mod_init: failed to initialize the DB support

Connect remote mysql to django

i have a MySQL database in cpanel and i want to connect my django project to this database when i try to connect it it show a message that i can't connect to localhost but i don't want to connect to localhost i want to connect to my remote database in cpanel.
i have tried to connect to (MySQL workbench) and it connected without a problem.
This is a picture of my settings and error

mysql-connector-c++ 8.0 connection refused

I'm using the mysql-connector-c++ 8.0 after getting it working with great difficulty and now the uri I've entered is as their mentioning in the docs but the connection is refused.
What the doc says:
Client cli("user:password#host_name/db_name", ClientOption::POOL_MAX_SIZE, 7);
My Code:
_mysql_client = std::make_unique<mysqlx::Client>("mysqlx://root:asdasd#localhost/asdasd");
try {
mysqlx::Session s = _mysql_client->getSession();
CoreLog->info("Successfully connected to mysql server on {}.", conn_uri);
} catch (const mysqlx::Error &err) {
CoreLog->info("Could not connect to mysql server on {} due to {}.", conn_uri, err.what());
}
and i get this error
[20:34:36.993] Core: Could not connect to mysql server on root:asdasd#localhost/asdasd due to CDK Error: Connection refused (generic:61).
What's the issue here?
mysqlx::Client is for connection to the new Mysql X protocol. This listens on a different port (33060 by default instead of 3306) which is the cause of the "connection refused" message.
You need to install and enable the Mysql protocol X plugin. See https://dev.mysql.com/doc/mysql-shell/8.0/en/mysql-shell-install.html for instructions.

How to connect to DB2 in robotframework (using Ride)

I can connect to the DB2 (IBM AS400) in Java Spring successfully using library jt400.jar and JDBC Driver: com.ibm.as400.access.AS400JDBCDriver
But not successful in Robotframework
I tried to use below code:
Connect To Database Using Custom Params jaydebeapi 'com.ibm.db2.jcc.DB2Driver','jdbc:db2://10.53.x.x/XABZ:user=USER1;password=PASS1'
Check If Exists In Database select * from lib.btmtran where tmtxseq = 187822
Disconnect From Database
I got the error
***** Out of Package Error Occurred (2018-07-24 16:55:25.3) *****
Exception stack trace: com.ibm.db2.jcc.am.SqlException: DB2 SQL Error:
SQLCODE=-805, SQLSTATE=51002, SQLERRMC=NULLID.SYSSH200;00;S6576b3b
, DRIVER=4.21.29
com.ibm.db2.jcc.am.kd.a(kd.java:815)
com.ibm.db2.jcc.am.kd.a(kd.java:66)
How to fix it ?

nanodbc connecting to MSSQL from Linux

I'm getting an "Invalid attribute value" when I try to connect to MSSQL from Linux.
My current /etc/odbcinst.ini file looks as follows:
[ODBC Driver 17 for SQL Server]
Description=Microsoft ODBC Driver 17 for SQL Server
Driver=/opt/microsoft/msodbcsql17/lib64/libmsodbcsql-17.1.so.0.1
Trace=yes
TraceFile=/home/mercury/Desktop/tracefile.txt
UsageCount=1
[ODBC Driver 13 for SQL Server]
Description=Microsoft ODBC Driver 13 for SQL Server
Driver=/opt/microsoft/msodbcsql/lib64/libmsodbcsql-13.1.so.9.2
UsageCount=1
My /etc/odbc.ini file looks like follows (information removed):
[TestServer]
Driver = ODBC Driver 17 for SQL Server
Server = $IP, $PORT
Database = $DATABASE
UserName = $Username
Password = $Password
If I run isql, I can connect with this command:
isql -v TestServer $Username $Password
Before I do the connection with nanodbc I print out the connection string that will be used which is:
DRIVER={ODBC Driver 17 for SQL Server};SERVER=$Server,$Port;DATABASE=$Database;Uid=$Username;Pwd=$Password
I then do:
nanodbc::connection(connectionString); which is where I get the
[unixODBC][Driver Manager]Invalid attribute value
error message.
So after a REALLY long time this turned out to be an issue with Ubuntu 16.04.
unixodbc on Ubuntu 16.04 reports its version wrong so when compiling nanodbc it uses the wrong version of unixodbc.
To fix this, recompile nanodbc with this cmake flag on:
For example:
mkdir build
cd build && cmake .. -DNANODBC_ODBC_VERSION=SQL_OV_ODBC3
This fixed the issue for me.
For future reference, this ticket was the answer: https://github.com/lexicalunit/nanodbc/issues/149