I apologize upfront for the length of this post. I want to try to capture as many details as possible and hopefully someone has insight on the problem. First, I am having trouble connecting to a remote database. I have tried Firebird, MySQL, MariaDB, and PostgreSQL. The problems are similar in each case.
my environment. I am using FPC 3.2.0 and Lazarus built from FPCUpDeluxe using the Fixes-3.0 branch. Shows as version 3.9 on the Lazarus splash screen. I am running all of this on a Mac running Sequoia. I have tried to use newer versions of FPC, but there is a known bug that is apparently tied to newer releases of Xcode that prevents a successful build of the latest versions of FPC.
I am working on an application that I initially used SQLite3 as the database. All was well, but I wanted to move to a multi-user database on a server that I can ultimately expose to the network. For each db (Firebird, MySQL, MariaDB, PostgreSQL) I have installed the server on a linux box (ubuntu). Configured the server for access via my home network and used a client on the server to create users and simple databases to test. All works. Again, for each, I installed at least the client software on the Mac. In most cases the only option was the full server and client install. I did that when necessary. I have tested with a variety of database connection components and have had various problems but I can't seem to get a connection.
The first, universal problem is finding the appropriate library. I have become very adept and finding the library and doing a sym link in the appropriate location to solve that problem for each of the DBs. After that I have run into problems that I can't solve. I use DBeaver for my local database SQL tool. I am able to connect to each of the servers/databases using that tool by providing similar parameters that the laz components require, host, port, database, user, password. DBeaver uses JDBC to connect. It connects and works flawlessly (is there a way to adopt JDBC in Las?).
I have narrowed my efforts down to only PostgreSQL for now. I tried them all, hoping one would break through and I would adopt that one. I am not wedded to Postgres and would happily switch to anything that works.
Right now I have PostgreSQL v16 installed on my Linux server. I have PostgeSQL v16 installed on my Mac (server and client). I have a simple test LAZ project that has only a TSQLConnector component and a TSQLTransaction component.
The TSQLConnector is configured as follows:
ConnectorType: PostgreSQL
Databasename: testdb
Hostname: <my Linux box>. -- note, I have used both the hostname and IP address in various tests
Name: SQLConnector1
Password: <my password for testdb>
Transaction: SQLTransaction1 -- the only other component on the form
-- all other values are default
The TSQLTransaction is configured as follows:
Database: SQLConnector1
Name: SQLTransaction1
-- all other values are default
When I attempt to change the Connected property on SQLConnector1 to True, I get an error that says
"Connection to database failed (PostgreSQL: connection to server at <my host> port 5432 failed: No route to host, Is the server running on that host and accepting TCP/IP connections?)
All of the parameters are correct. It accurately decodes my host name to the correct IP address and shows that in the error message. The Port is correct. The UID and Password are correct. Is there something that I need to be doing regarding TCP/IP that I am unaware of? While I don't know how to identify if DBeaver or the local PostgreSQL client are using TCP/IP connections (I can't imagine they are not) but important to note that they both work from the same machine where I am writing Laz code. For those familiar with PostgreSQL setup, I have set the config for "listen_addresses = '*'" and "host all all 192.168.1.1/24 password" in pg_hba.conf (for those that are security conscious, I plan to tighten that later). These config values have to be correct or I would not be able to connect remotely using the PostgreSQL client and DBeaver.
As best I can tell, the problem resides in Lazarus, FPC, or most likely, something that I should know to do that I just don't. I have been banging my head on this for the better part of a week. At this point, I have tried many different components, all the different databases, and all of the advice I can glean from searching the web. I really hope someone can point out whatever stupid mistake I am making. Fell free to point me down rabbit holes, I have been trying anything that is within my limited ability and I have managed to learn a lot of stuff. Unfortunately, I have not learned the answer to how to connect to a remote database of any stripe.
Thanks
