On Thursday, 22 October 2020 at 18:43:40 UTC, Steven Schveighoffer wrote:
On 10/22/20 11:00 AM, Vino wrote:
[...]

Different error:

 Row[] data = conn.query("SELECT * FROM hostlog").array;

This is trying to call mysql-native's UFCS query function on Connections, which isn't valid. You need to call it on conn.conn.

But there's no access to the private Connection conn inside the Connections class. I'm not sure what the class is for anyway, so it's hard for me to suggest a proper alternative. Are you just trying to encapsulate the connection string? I'd suggest instead of a whole class, just a factory function:

Connection getConnection()
{
   return new Connection("...");
}

-Steve

Was about to say that. Part of why I think some people hate OOP...due to misuse.

All my MySQL projects have this getConnection() function.

Reply via email to