Can't create a database link for CMS WebGUI - sql-server

I've updated the whole scenario (last one was a conflict between i686 and x64 libraries)
Now I have an VPS with a fresh CentOS 6.6 32 bit with unixODBC, FreeTDS and WebGUI installed
I can connect perfectly with SQL Server 2008 through isql and perl scripts.
BUT my goal is to create a database link for WebGUI (an open-source CMS based in perl)
Output for odbcinst -j
unixODBC 2.3.4
DRIVERS............: /etc/odbcinst.ini
SYSTEM DATA SOURCES: /etc/odbc.ini
FILE DATA SOURCES..: /etc/ODBCDataSources
USER DATA SOURCES..: /root/.odbc.ini
SQLULEN Size.......: 4
SQLLEN Size........: 4
SQLSETPOSIROW Size.: 2
/etc/odbcinst.ini
[FreeTDS]
Description=v0.95.73
Driver=/usr/lib/libtdsodbc.so.0.0.0
UsageCount=1
/etc/odbc.ini
[DSN]
Description=DNS description
Driver=FreeTDS
Server=XX.XX.XX.XX
Database=myDatabase
Port=1433 #sql server default port
TDS_Version=7.3
Trace=Yes
TraceFile=/tmp/sql.log
When I execute this perl script, it runs ok.
#!/usr/bin/perl
use strict;
use warnings;
use DBI;
use DBD::ODBC;
my $dsn = "DBI:ODBC:DSN"; # Same DSN as above
my $db_user = "dbuser";
my $db_pass = 'dbpass';
my $dbh = DBI->connect($dsn, $db_user, $db_pass) or die "$DBI::errstr\n";
print "Connected\n";
my $query = "Select * from myTable";
my $sth = $dbh->prepare($query) or die "$DBI::errstr\n";
$sth->execute or die "$DBI::errstr\n";
# go do stuff!
# Close the database
$sth->finish;
$dbh->disconnect;
This is the database link I'm trying to add to WebGUI
When I commit the changes, I get this error in my browser:
Proxy Error
The proxy server received an invalid response from an upstream server.
The proxy server could not handle the request POST /home.
Reason: Error reading from remote server
modproxy.error.log
[Wed Dec 23 14:15:42 2015] [error] [client IP] proxy: Error reading from remote server returned by /home, referer: http://VPSIP/home?op=editDatabaseLink;dlid=y2Yf1_oEJD6-Wm-T-yHy-w
[Wed Dec 23 14:15:58 2015] [error] [client IP] (20014)Internal error: proxy: error reading status line from remote server 127.0.0.1:8081, referer: http://VPSIP/home?op=editDatabaseLink;dlid=y2Yf1_oEJD6-Wm-T-yHy-w
[Wed Dec 23 14:15:58 2015] [error] [client IP] proxy: Error reading from remote server returned by /home, referer: http://VPSIP/home?op=editDatabaseLink;dlid=y2Yf1_oEJD6-Wm-T-yHy-w
modperl.error.log
[Wed Dec 23 14:15:59 2015] [notice] child pid 7766 exit signal Segmentation fault (11)
Maybe WebGUI is trying to load the /home from SQL Server instead of mysql? (I just want to connect to SQL Server to fetch some products, nothing else)
Any help would be appreciated
Regards

Try: export LD_LIBRARY_PATH=/usr/local/lib
Source

In your odbc.ini, you specify the DRIVER defined in odbcinst.ini.
Try this for odbc.ini:
[DSN]
Description=DNS description
Driver=FreeTDS
Server=XX.XX.XX.XX
Database=myDatabase
Port=1433 #sql server default port
TDS_Version=7.3
Also, be sure you use the right TDS Version for the SQL Server version and FreeTDS version you're using. I'd recommend sticking with 7.2 unless you need 7.3: http://www.freetds.org/userguide/choosingtdsprotocol.htm I've got example odbc.ini, odbcinst.ini and freetds.conf files in this repo, if they help: https://github.com/FlipperPA/django-python3-vagrant/tree/master/examples
Good luck!

OK, just added
use DBD::ODBC;
to the file SQL.pm and WebGUI is able to recognize unixODBC (and FreeTDS, too).
Merry X'Mas!!! :D

Related

QT unable to connect to mssql server from qt application in ubuntu

Unable to connect to mssql server from qt application in ubuntu 20.04
Sql server located in windows 7
The connection is definitely present, because it was possible to connect through DDbeaver.
Can anyone help me in this situation?
Code:
QSqlDatabase db = QSqlDatabase::addDatabase("QODBC3");
db.setConnectOptions();
QString serverName = "566***";
QString ipName = "tcp:192.168.144.101,1433";
QString dbName = "St***";
QString connectionString = QString("DRIVER={ODBC Driver 18 for SQL Server};Server=%1;Database=%2;").arg(ipName).arg(dbName);
db.setDatabaseName(connectionString);
db.setUserName("sa");
db.setPassword("top123TOP");
if (db.open())
{
qDebug() << "Correct connection";
}
else
{
QString error = db.lastError().text();
qDebug() << error;
}
otuput is:
"[Microsoft][ODBC Driver 18 for SQL Server]TCP Provider: Error code 0x2746 [Microsoft][ODBC Driver 18 for SQL Server]Client unable to establish connection QODBC3: Unable to connect"
odbcinst.ini
[ODBC Driver 18 for SQL Server]
Description=Microsoft ODBC Driver 18 for SQL Server
Driver=/opt/microsoft/msodbcsql18/lib64/libmsodbcsql-18.0.so.1.1
the following solution helped:
from:https://github.com/microsoft/msphpsql/issues/1112
This was helpful.
Ubuntu 20.04 PHP 7.4 using the 19.10 drivers for sqlsrv
We have a real old SQL server out there . The SQL Server show's version 10.50.2550.0, i think it's SQL Server 2008 R2. I had to use TLSv1 to connect to the server. I also had to do a "systemctl restart apache2" to get it to take affect. TLSv1.1 did not work with my MSSQL server version.
Error message: Connection failed: SQLSTATE[08001]: [Microsoft][ODBC Driver 17 for SQL Server]SSL Provider: [error:1425F102:SSL routines:ssl_choose_client_version:unsupported protocol]Database Connection Error
edit: /etc/ssl/openssl.cnf
1st line in the file added
openssl_conf = default_conf
End of file added
[default_conf]
ssl_conf = ssl_sect
[ssl_sect]
system_default = system_default_sect
[system_default_sect]
MinProtocol = TLSv1
CipherString = DEFAULT#SECLEVEL=1
Not 100% sure why i had to restart apache2 for it to take effect, but I had to.
systemctl restart apache2
reloaded the page and it works

Login failed for the user '' SQL Server when connecting using python from EMR server

I'm trying to connect to SQL Server Database from AWS EMR server.
$cat /etc/odbcinst.ini
[ODBC Driver 17 for SQL Server]
Description=Microsoft ODBC Driver 17 for SQL Server
Driver=/opt/microsoft/msodbcsql17/lib64/libmsodbcsql-17.8.so.1.1
UsageCount=1
and I modified the .odbc.ini file in my home directory like this.
$cat .odbc.ini
[ODBC Data Sources]
studylog = ODBC17Driver
[studylog]
Driver = /opt/microsoft/msodbcsql17/lib64/libmsodbcsql-17.8.so.1.1
Description = My Description
Server = hostname.amazonaws.com
output of odbcinst -j command
unixODBC 2.3.7
DRIVERS............: /etc/odbcinst.ini
SYSTEM DATA SOURCES: /etc/odbc.ini
FILE DATA SOURCES..: /etc/ODBCDataSources
USER DATA SOURCES..: /mnt/efs/home/username/.odbc.ini
SQLULEN Size.......: 8
SQLLEN Size........: 8
SQLSETPOSIROW Size.: 8
output of odbcinst -q -d command
[ODBC Driver 17 for SQL Server]
output of odbcinst -q -s command
[studylog]
Python script I'm using to connect to SQL Server
import pyodbc
host = "hostname.amazonaws.com"
user="DBUser"
password="Password"
db="dbname"
details = {
'server' : host,
'database' : db,
'username' : user,
'password' : password
}
# ODBC Driver 17 for SQL Server
connect_string = 'DRIVER={{ODBC Driver 17 for SQL Server}};SERVER={server};PORT={{1433}}; DATABASE={database};UID={username};PWD={password}'.format(**details)
connection = pyodbc.connect(connect_string)
print(connection)
output of my python script
pyodbc.InterfaceError: ('28000', "[28000] [Microsoft][ODBC Driver 17 for SQL Server][SQL Server]Login failed for user 'DBUser'. (18456) (SQLDriverConnect)")
What's going wrong in this? Thank you in advance.

Kafka-Connect For MSSQL Invalid value java.sql.SQLException: No suitable driver found for for configuration

I am trying to connect kafka-connect to my local mssql with localhost:3030
I am receiving this error when I try to make a new connection for mssql. in centos 7(linux). Mssql data is from an external IP(windows), my consumer is inside of linux environment.
"No suitable driver found for configuration".
connect-distributed.properties is shown below;
plugin.path=/usr/local/share/java,/usr/local/share/kafka/plugins,/opt/connectors,
I added "ojdbc7-12.1.0.2.jar" file under /opt/connectors/kafka-connect-jdbc/ but still I am receiving error messages. I dont know what is wrong.
Also my connect-console-source.properties
name=source-sqlserver-user
connector.class=io.confluent.connect.jdbc.JdbcSourceConnector
tasks.max=1
topic.prefix=my-timestamp
connection.url=jdbc:sqlserver://externalIP;database=database;username=username;password=password
version: '2'
services:
kafka-cluster:
image: landoop/fast-data-dev:cp3.3.0
environment:
ADV_HOST: 127.0.0.1
RUNTESTS: 0
ports:
- 2181:2181 # Zookeeper
- 3030:3030 # Landoop UI
- 8081-8083:8081-8083 # REST Proxy, Schema Registry, Kafka Connect ports
- 9581-9585:9581-9585 # JMX Ports
- 9092:9092 # Kafka Broker
ojdbc7-12.1.0.2.jar is the JDBC driver for Oracle.
For MS SQL you need the MS SQL JDBC driver
Edit: Since you're using Docker to run Kafka Connect, you need to make the JDBC JAR file available to the Kafka Connect worker before it runs. You can't just run the Docker container and copy the JDBC driver into it, because you need to restart Kafka Connect afterwards.
To workaround this, you can mount the JAR from your local machine to the relevant path in the container. The relevant path is whereever the Kafka Connect JDBC jar is. Looking at the fast-data-dev image it's in
root#fast-data-dev / $ ls -l /opt/confluent-3.3.0/share/java/kafka-connect-jdbc
total 6544
-rw-r--r-- 1 root root 133842 Jul 28 2017 kafka-connect-jdbc-3.3.0.jar
-rw-r--r-- 1 root root 658466 Jul 28 2017 postgresql-9.4-1206-jdbc41.jar
-rw-r--r-- 1 root root 5575351 Jul 28 2017 sqlite-jdbc-3.8.11.2.jar
So you can run
docker run --rm --net=host --volume ~/Downloads/mssql-jdbc-7.4.1.jre8.jar:/opt/confluent-3.3.0/share/java/kafka-connect-jdbc/mssql-jdbc-7.4.1.jre8.jar landoop/fast-data-dev:cp3.3.0
or mount it in your Docker Compose with a volumes config:
version: '2'
services:
kafka-cluster:
image: landoop/fast-data-dev:cp3.3.0
environment:
ADV_HOST: 127.0.0.1
RUNTESTS: 0
ports:
- 2181:2181 # Zookeeper
- 3030:3030 # Landoop UI
- 8081-8083:8081-8083 # REST Proxy, Schema Registry, Kafka Connect ports
- 9581-9585:9581-9585 # JMX Ports
- 9092:9092 # Kafka Broker
volumes:
- ~/Downloads/mssql-jdbc-7.4.1.jre8.jar:/opt/confluent-3.3.0/share/java/kafka-connect-jdbc/mssql-jdbc-7.4.1.jre8.jar
It's worth noting that Confluent Platform 3.3.0 is really old - the latest is 5.3.1. If you want to see an up-to-date example of running Kafka, Kafka Connect, SQL Server etc with JDBC driver automatically set up see this example here.

Connect to SQL Server in local machine (host) from docker using host.docker.internal

I'm trying to connect to my SQL Server instance running in my local computer using host.docker.internal (as recommended in https://docs.docker.com/docker-for-windows/networking/#use-cases-and-workarounds)
The host.docker.internal is successfully resolved to an IP, and it's ping-able
And I've opened up the port 1433 in my firewall configuration
Error message
Connection refused 192.168.65.2:1433
My connection string
Data Source=host.docker.internal,1433;Initial Catalog=;Persist Security Info=False;User ID=;Password=;MultipleActiveResultSets=True;Encrypt=True;TrustServerCertificate=False;Connection Timeout=30;
docker version
Client:
Version: 18.03.1-ce
API version: 1.37
Go version: go1.9.5
Git commit: 9ee9f40
Built: Thu Apr 26 07:12:48 2018
OS/Arch: windows/amd64
Experimental: false
Orchestrator: swarm
Server:
Engine:
Version: 18.03.1-ce
API version: 1.37 (minimum version 1.12)
Go version: go1.9.5
Git commit: 9ee9f40
Built: Thu Apr 26 07:22:38 2018
OS/Arch: linux/amd64
Experimental: true
Docker for windows version
If anyone have similar problem, here's how I solve it
Open SQL Server Configuration Manager
Enable TCP/IP in Server Network Configuration
Restart SQL Service Service
If it's still not working, there are a few more things to check
Firewall (open port 1433)
Enable remote connections to your sql server

Perl ODBC Driver error. Can't insert data into Remote SQL Server Database

I am trying to run a perl script to insert data into a remote SQL Server Database. I have installed the DBI module and ran the following commands:
aptitude install tdsodbc
dpkg-reconfigure tdsodbc
aptitude install unixodbc-dev
cpan DBD::ODBC
to install the DBD:ODBC driver.
This is the error I keep getting in my /var/log/apache2/error.log:
[Fri Jul 29 13:51:53.838633 2016] [cgi:error] [pid 27482] [client MY_IP:49390] AH01215: Perhaps the DBD::ODBC perl module hasn't been fully installed,, referer: http://MY_IP:8080/
[Fri Jul 29 13:51:53.838649 2016] [cgi:error] [pid 27482] [client MY_IP:49390] AH01215: or perhaps the capitalisation of 'ODBC' isn't right., referer: http://MY_IP:8080/
[Fri Jul 29 13:51:53.838667 2016] [cgi:error] [pid 27482] [client MY_IP:49390] AH01215: Available drivers: DBM, ExampleP, File, Gofer, Proxy, Sponge, mysql., referer: http://MY_IP:8080/
[Fri Jul 29 13:51:53.838681 2016] [cgi:error] [pid 27482] [client MY_IP:49390] AH01215: at /var/www/html/src/cgi-bin/login.pl line 88., referer: http://MY_IP:8080/
[Fri Jul 29 13:51:53.854105 2016] [cgi:error] [pid 27473] [client MY_IP:49386] AH01215: install_driver(ODBC) failed: Can't locate DBD/ODBC.pm in #INC (you may need to install the DBD::ODBC module) (#INC contains: GeoIP/Geo-IP-1.38/lib/ /etc/perl /usr/local/lib/perl/5.18.2 /usr/local/share/perl/5.18.2 /usr/lib/perl5 /usr/share/perl5 /usr/lib/perl/5.18 /usr/share/perl/5.18 /usr/local/lib/site_perl) at (eval 177) line 3., referer: http://MY_IP:8080/
Here is my code to connect with the database (login.pl):
my $database = "<DB NAME>";
my $host = "<REMOTE_IP>";
my $username = "<USERNAME>";
my $password = "<PASSWORD>";
my $dbs = "dbi:ODBC:DRIVER={FreeTDS};SERVER={$host};DATABASE=$database";
# Invoke connection to MySQL
#my $connection = ConnectToMySql($database, $host, $username, $password);
my $connection = DBI->connect($dbs,
$username,
$password,
{RaiseError => 1, AutoCommit => 1}) or die ("Can't connect to database $database on $host: " . $DBI::errstr . "\n");
Message when running cpan DBD::ODBC:
This looks like a unixodbc type of driver manager.
Looking for odbcinst
Found odbcinst in /usr/bin
odbcinst -j reports:
unixODBC 2.2.14
DRIVERS............: /etc/odbcinst.ini
SYSTEM DATA SOURCES: /etc/odbc.ini
FILE DATA SOURCES..: /etc/ODBCDataSources
USER DATA SOURCES..: /home/openflow/.odbc.ini
SQLULEN Size.......: 8
SQLLEN Size........: 8
SQLSETPOSIROW Size.: 8
Please note these files as they are where you define your ODBC drivers and data sources.
Looking for odbc_config to get cflags
odbc_config not found - ok
Warning: LD_LIBRARY_PATH= doesn't include /usr/lib/x86_64-linux-gnu
Checking if your kit is complete...
Looks good
Using DBI 1.63 (for perl 5.018002 on x86_64-linux-gnu-thread-multi) installed in /usr/lib/perl5/auto/DBI/
Using DBI 1.63 (for perl 5.018002 on x86_64-linux-gnu-thread-multi) installed in /usr/lib/perl5/auto/DBI/
Writing Makefile for DBD::ODBC
Writing MYMETA.yml and MYMETA.json
Warning: not all required environment variables are set.
Warning: Will not be able to run tests as you have not defined
all of DBI_DSN, DBI_USER and DBI_PASS environment variables.
MJEVANS/DBD-ODBC-1.52.tar.gz
make -- NOT OK
'YAML' not installed, will not store persistent state
Running make test
Can't test without successful make
Running make install
Make had returned bad status, install seems impossible

Resources