Error connecting using JDBC Mysql - mysql

I'm not able to establish a connection to my MySQL server.
This is the connection string:
jdbc:mysql://<my_IP_address>:1005/rs_pm
This is the line of code:
var conn = Jdbc.getConnection(connString, mysql_user, mysql_pass);
I've been able to write a native Java program using JDBC and it connects just fine using the same connection string/username/password. (Yes, I know the port is non-standard but that's how I have it configured and it works with the native Java app).
The weird thing is, I'm looking at my router logs and when I try to connect with a native Java app I can see the traffic coming in. But when I run the script in G Apps I don't see any packets being received by Google IP addresses.
Is it just me? Is there a problem somewhere?
Thanks in advance.
Update So it appears that if I use the standard mysql port (3306), the connection works fine. It seems as though something in Google Apps won't try an outbound connection on the port I had specified (1005), or any other ports I tried. Perhaps the jdbc connector they use only supports port 3306? I will file a bug since this behavior isn't documented anywhere.

JDBC connection to a database server only supported to ports 1025 and higher.

Related

Using firebase functions emulator with cloud SQL proxy

I deployed a firebase https function that calls a GCP MySQL instance and returns some data. How can I run this function in the firebase function emulator?
I loaded the function into the emulator along with a simple helloWorld https function. That returns nicely with the local URL (http://localhost:5001/INSTANCE/us-central1/helloWorld). The locally run SQL https function, however, returns
{"errno":-4058,"code":"ENOENT","syscall":"connect","address":"/cloudsql/(deleted)","fatal":true}
... where I've deleted the instance connection name.
Next, I run gcloud_sql_proxy on my PC, and it claims to be listening on 127.0.0.1:3306. The https function continues to return the exact same error above, so I'm not sure if the emulated function is going through my gcloud_sql_proxy or still trying to connect to the cloud SQL directly - I am guessing the latter.
Should I also re-instrument the function itself to connect using host+port (127.0.0.1, 3306) versus the unix socketpath method that it's currently using? I was hoping the emulator would automagically do that so I can avoid going down that rabbit hole, as the cloud documentation only provided the socketpath method. But I do plan to try that next.
Thank you.
Based on the error message, I think the emulator is looking for a Unix socket and it sounds like you're starting the Cloud SQL Proxy with a TCP socket.
Try using a Unix socket whose path matches your function. Something like:
cloud_sql_proxy -dir /cloudsql
This will create a Unix socket for all SQL instances in your active gcloud project.

The response is not returned from Azure Database for MySQL when I try to connect from command prompt and MySQL Workbench

I run into the problem which I wrote as a Title.
The details are below.
Environments and Settings
using the Azure free plan.
created Azure Database for MySQL server (version 8.0).
Deny public network access: No
added firewall rule Start IP: 0.0.0.0 - End IP: 255.255.255.255.
Enforce SSL connection: DISABLED
Client OS: Windows 10 Pro Version 2004 OS Build 19041.685
Overview
Connection security
Ehenomenon
I can connect from Azure Cloud Shell.
I can connect from local DBeaver client (Community Edition 21.2.3).
However, I cannot connect from local Command Prompt or MySQL Workbench. The response is not returned.
It seems to be hanged out. I allowed these apps to communicate via Windows Defender firewall.
Azure Cloud Shell
DBeaver
Command Prompt
MySQL Workbench
Firewall
What's wrong? Please help.
It looks like there is a problem with the latest MySQL 8.0.27 release. I've encountered the same issues you describe when trying to connect using the command line from different MacOS and Linux machines.
There 's also a bug reported here: https://bugs.mysql.com/bug.php?id=105288
I suggest you add your findings to it as well.
I tried a bunch of different things before simply rolling back to 8.0.26, which still works fine for me.

Arduino + Sim900 + MySql connection problem

I'm doing a project where I must do a query to a mysql server with the Sim900 module throught Arduino. Let me explain what I have, so that you can help me:
Arduino Uno (original version)
Sim900 module (https://www.amazon.es/gp/product/B07FS34P84/ref=ppx_yo_dt_b_asin_title_o02_s00?ie=UTF8&psc=1)
5V/2A Power Supply Adapter for Sim900 (https://www.amazon.es/gp/product/B07DX11WJJ/ref=ppx_yo_dt_b_asin_title_o00_s00?ie=UTF8&psc=1)
Windows Server 2012 with Static Ip (xxx.xxx.xx.xx), with a MySql Server that allows external connections (with an extern computer or smartphone, I can access the db)
First of all, I tried to do a query with the GChrome, like http://xxx.xx.xxx.xxx:3306/connect.php but this didn't worked. Then, I downloaded XAMPP and connected Apache and MySql. At that time, I writted in the Chrome search bar: http://localhost/connect.php and it said: Connected successfully so, at that moment I knew that I connected to the db.
So, I tried to connect with AT commands: First of all, I connected with the APN
AT+CSTT= "airtelnet.es", "vodafone", "vodafone"
and then I tried to connect with TCP to the server
AT+CIPSTART="TCP","xxx.xx.xxx.xxx","3306"
At this moment, the Serial Monitor gave me some errors and special characters.
Can someone help me with this?, what am I doing wrong?
Not sure what you want to do. Are you using sim900 for gprs as internet connection for Arduino? Do your arduino has shield for LAN cable.
If so, your xampp mysql should work as API server. Arduino will call url to send data, mysql is just internal job of server, no directly connection with arduino.

Google App script and local database connectivity

I have mysql server installed on my machine. I would like to connect to the same local mysql instance using Google app script's jdbc service. I am getting connection failed error. So, I would like to confirm:
1. is it possible to connect to mysql instance running on private machine(laptop) using jdbc service.
2. If not is it always mandatory to connect to public IP. What is the alternative to connect to mysql instance running on private machine.
This definitely works, but you need to permit Google's machines to connect to your machine. That means opening a hole in your firewall, possibly setting up port forwarding on your router, etc.
There is an alternative to poking a hole in your security arrangement, it is called Secure Data Connector, and it lets your machine initiate the connection to Google - https://developers.google.com/secure-data-connector/
Unfortunately, I don't believe that SDC supports JDBC yet (I believe it only supports HTTP based communication).
(P.S. One very simple work around is to mirror your local database to some kind of cloud service, and then permit access to that replica from Google).

Accessing MySQL Database from my VB.NET 2008 Project

I developed a project in VB.NET
In this project I want to use data from MySQL that is resides in my WEB Server.
I can communicate with the MySQL server of my localhost but can not communicate with the WEB Server.
In my CPanel I added Host from the Remote Database Access
But I can't communicate with WEB MySQL Server.
Please help me.
The first step is to try to connect to the web mysql with MySql Query Browser - that will tell you if the database is open for remote connections ( I assume it would fail)
I guess you have already checked it, but make sure you use the correct ip
EDIT:
As Björn said, your vb code is ok, so the problem is with the connection to the db.
Unfortunately that would be caused by many many reasons.
Are you sure you use a real IP from the host (and use it in the mysql settings)?
Are you sure you entered the correct remote host in the mysql settigns?
Are you sure you have correct connection string in the vb code?
Since your post indicates you can access the DB on your localhost, it doesn't seem to be an issue with the way you're connecting to the DB from your application (.NET-Connector?).
What does the external MySQL-Server say? Access denied? Or can't you reach it from the pc where your application is hosted (aka maybe a firewall regulation, other network etc.)?