PostgreSQL Bytea column as varchar results - postgresql

I have this client where we installed a PGSQL server on his server (PGSQL 13 on port 5432)
There already was a postgresql server installed (8.3, port 15432).
No problems here.
Our application has a few 'bytea' columns where we store some encrypted data. Strange things happen when I launch a SQL on this column.
Exactly the same code gives different results on different computer.
For example: "Select ByteAColumn from RandomTable"
Results on my computer:
"E712F7671E929600C926003C61C4C696C27E89C8D836F85898737799DFAB1CC4"
Result on server where the Postgresql is installed:
"\x45373132463736373145393239363030433932363030334336314334433639364332374538394338443833364638353839383733373739394446414231434334"
Result on other computer in the network of the client:
"E712F7671E929600C926003C61C4C696C27E89C8D836F85898737799DFAB1CC4"
Result on "Select ByteAColumn::varchar from RandomTable" in PGAdmin 4:
\x45373132463736373145393239363030433932363030334336314334433639364332374538394338443833364638353839383733373739394446414231434334
My application expects the "E712F7671E929600C926003C61C4C696C27E89C8D836F85898737799DFAB1CC4" one and throws error on the result with '\x4...'.
I can avoid this using "Select encode(ByteAColumn,'escape') from RandomTable", this gives the right results. Modifying our entire application is near impossible.
In other words: the application runs fine on my computer, works fine on client computers / terminal server but not on the server where the postgreSQL database is hosted.
I've been using this application for over a year now. I have done many installations of this application and never have had this issue before. I've tested the query on other installations where everything is fine, and there I also get the '\x45...' result, but using the query in my application works great.
What causes this?
Is it the PostgreSQL 8.3 server which interferes somehow? I've been testing and searching a whole day now and I can't seem to find the answer.
Help would be greatly appreciated.
Thanks!

Related

Mongosqld runs fine, but ODBC fails on test and PowerBI throws error 10060. Connector not working. Windows to two seperate RHEL Servers

The Goal
I need to get data from a MongoDB updated every 15 minutes to use to build into a PowerBI report.
The Gear
I am connected from my windows machine via ssh to an RHEL server (server a). This server is running powerbi connector (SQLD) which is connected to my MongoDB that is running on a different server (server b). I'm also running MySQL on server b. My powerBI connector is installed on server b.
Exactly where I'm at
I am using the steps listed here (and all the associated pages) and have tried everything listed short of writing a config file, as the fact that things are working on mongosqld's end makes me think I don't need it... and if I can't get it working manually, having a config file won't exactly help.
https://docs.mongodb.com/bi-connector/current/connect/powerbi/
Using:
mongosqld --mongo-uri="mongodb://10.xxx.xxx.xx" --auth --mongo-username="ThisGuy" --mongo-password="test"
I successfully map the schema and show an active connection in the command window. I can also access my database from compass using an authorization enabled URL.
When I set up an ODBC connector I use the IP of server a, the user and password from my url, and port 3307. Nothing shows up in the dropdown, when I click 'test' I get the following message:
Connection Failed
[MongoDB][ODBC 1.4(w) Driver]Can't connect to MySQL server4 on '10.xxx.xxx.xxx' (10060)
I have also tried 3306, 27017, and 27015. Just to be safe I also added firewall rules for all traffic on these ports. I've tried this many times, including (just for the hell of it, and I'm kind of new to this stuff) the ip of server b, the ip of my machine, the credentials for MySQL, basically any combination of these things that I can think of.
In powerBI, my odbc driver shows up, and when selected in the dropdown, it asks for a username and password. I have tried both mongo credentials and MySQL. Not sure which I should be using?
regardless, I get the following error inside PowerBI:
Details: "ODBC: ERROR [HY000] [MySQL][ODBC 1.4(w) Driver]Can't connect to MySQL server on '10.xxx.xxx.xxx' (10061)
ERROR [HY000] [MySQL][ODBC 1.4(w) Driver]Can't connect to MySQL server on '10.xxx.xxx.xxx' (10061)"
Thoughts
I don't control either server, although I have root access, being new to this tech and company I am wary of screwing anything up that a co-worker will have to fix. I read in a different SO thread that maybe I need to downgrade the version of MySQL that is running on the server and that it could fix the problem, but I don't think that it will actually help and am afraid I might screw up something else on the server if I do this:
The C Authentication plugin was developed against MySQL 5.7.18 Community Edition (64-bit), and tested with MySQL 5.7.18 Community Edition and the latest version of MongoDB Connector for BI. The plugin is not compatible with MySQL Server or Connector/ODBC driver version 8 and later.
https://dba.stackexchange.com/questions/219550/access-denied-when-connecting-to-mongosqld-with-mysql
Maybe the problem is that server B is listening to server a on port 3307, and that there is another unknown port (not mentioned above) that my ODBC driver must be listening to? I'm not sure how to test for this when you get a step away like this.
So that's it. I'm really stuck and would love some help, I am going to try the downgrade tomorrow if nothing else shakes loose and will keep this thread updated.
Thank you for reading

MySQL Workbench 6.3 not returning results with more than 2000 rows

I am running MySQL Workbench 6.3 on a Windows 7 machine 64-bit laptop. When a do a simple query to get all the data in a single table with ~400 rows of data, the query stays in "running . . . " status and eventually returns the Error Code: 2013 Lost Connection to MySQL server at "waiting for initial communication". If I limit the results to 1000 rows, the query works fine, its only when I allow for more than 2000 rows does this occur.
I do have "Use compression protocol" enabled, which I had hoped would fix the issue.
The other thing I noticed, that if I run the query on my Mac I do not have this issue, I get more than 10,000 rows with no issues.
Has anyone else had this issue and resolved it?
~michemali
Seems like a time out issue. Please refer to this post to see if this resolves your issue:
MySQL Workbench: How to keep the connection alive

Can't connect to postgresql server installed locally on my machine

I have installed the DSP(Dreamfactory Service Platform) locally on my Mac Book Pro using Bitnani.
I have a PostGreSQL server running locally on my Macbook, which I want to connect to using the DSP.
I am successfully able to connect to my PostGreSQL server from other applications, which essentially means that there is no problem with the setup.
However, on trying to connect the same from DSP I get the error:- "Failed to launch service "sql": CDbConnection failed to open the DB connection."
My connection string is :- "pgsql:host=localhost;dbname=Pinu"
Also, the password has been correctly entered.
The port is default as 5432. Whether or not I enter the same in the connection string, the connection always fails.
Even though I am trying to add the service as Remote SQL DB, I know that it's actually on the same local host. Not sure if that is the issue.
I also tried entering - 127.0.0.1 in place of localhost, but still I see the same issue.
Any help in this regard would be highly appreciated!
After talking to you via email, it looks like the root issue here is that you haven't successfully upgraded your DSP to the latest version. We are releasing DreamFactory version 1.8 on Bitnami tomorrow, so you should upgrade to the latest version.
As far as your PostgreSQL issue let's explore some options:
1) Connection strings:
a) pgsql:host=localhost;dbname=Pinu
b)
pgsql:host=localhost:5432;dbname-Pinu
c)
pgsql:host=localhost;port=5432;dbname=Pinu
2) If these don't work, try substituting your localhost with
127.0.0.1 (as you've tried previously, but test this in all scenarios).
3)
pgsql:host=localhost;port=5432;dbname=series1;schema=schema_name_here
Typically, Option A should work without a problem.
Give these a try if you would, and if you need some help upgrading then reach out to me again via email.
--Thanks,
Mark

How does ODBC pull database connection details?

I currently have a Macro which is connecting to a sybase database using ODBC. It's making the connection by running the following:
Set conX = wrkODBC.OpenConnection("Connection1", , True, strConn)
where strConn = "ODBC;DSN=Server_Name;APP=Daily Task;DB=db_name;UID=uname;PWD=pwd;"
The problem I am having is that this connection is working for some Server_Name's but not others. When it doesn't work I get a Error "3146 - ODBC--call failed".
What I don't understand is where it is pulling the server details from. So for example, when using embarcadero rapid to connect to a sybase database, it will use the sql.ini file to pull the server connection details based on the server_name.
I have checked and all the Sybase Servers I am testing are in the sql.ini file and my env variables are pointing to the correct sybase version. I've checked ODBC and it is only picking up a SQL Server driver.
Can anyone please explain how ODBC pulls the server name connection details? I don't understand why it works for some server names, but not others (FYI, I have tested the uname and pwd is rapid to make sure it is correct).
Any information would be much appreciated.
So, the issue was that I was looking at my odbc connections under control panel. I should mention that I am on windows 7. What I had to do was update my ODBC connection details here:
C:/Windows/SYSWOW64/odbcad32.exe
--This is for 32bit!
This had some connections set up which is why I could connect to some servers but not all of them.

How to check remote Oracle server is up and running

I have my Oracle server installed in a remote machine and I want a script at my local machine which will check whether Oracle server is up and running or not. I know this can be check by creating a connection through sqlplus or JDBC. But in this case oracle client won't be present and I am saving JDBC approach as my last option. So is there any other simpler way to check this, which can be easily implemented in a shell script???
Thanks
Not really. The only way to be certain that the database is responding to queries is to run a query on it, such as the venerable:
select dummy from dual