If you don't want to use JDBC test elements for building a database test plan you can always switch to JSR223 Test Elements and program whatever you want using Groovy language, in your case your friend is groovy.sql.Sql
Example code:
def dburl = 'jdbc:mysql://192.168.99.100:3306/mysql'
def user = 'root'
def password = props.get('db.password')
def driver = 'com.mysql.cj.jdbc.Driver'
groovy.sql.Sql.withInstance(dburl, user, password, driver) { sql ->
sql.query('select name,url from help_topic order by rand() limit 2;') { resultSet ->
while (resultSet.next()) {
def name = resultSet.getString(1)
def url = resultSet.getString('url')
log.info('Topic name: ' + name + ' topic url: ' + url)
}
}
}
Example output:

This line: props.get('db.password')
is reading the value from JMeter Properties, you can set the property value using -J command-line argument like:
jmeter -Jdb.password=secret -n -t test.jmx -l result.jtl
Check out Apache Groovy - Why and How You Should Use It article for more information on Groovy scripting in Jmeter
You will still need to have MySQL Connector/J in JMeter Classpath