Validate application to access the database
No matter what safeguards you put in place on the server side, it will always be possible for a client to fake a connection. This is an inherent limitation of the client-server model - the server can only gather information about the client by querying the client, and the client can always be configured to lie.

You cannot completely protect against this without the use of middleware. If you only allow the middleware to connect directly to the database e.g. by ip blocking, then you can have complete control of what commands can and can't be sent to the database.