From the preceding diagram, it is clear that depending on the database client we use, a different connection will be used and created. Now, let's have a look at the code representation for the preceding diagrams. First is the SimpleConnection with its concrete implementations:
trait SimpleConnection { def getName(): String def executeQuery(query: String): Unit}class SimpleMysqlConnection extends SimpleConnection { override def getName(): String = "SimpleMysqlConnection" override def executeQuery(query: String): Unit = { System.out.println(s"Executing the query '$query' the MySQL way.") }}class SimplePgSqlConnection extends SimpleConnection { override def getName(): String = "SimplePgSqlConnection" override def executeQuery ...