String function
AdaBase.Driver.Base.[DB].trait_client_version ()

This is a connection attribute. It returns the version number as reported by the database client as a string.


String function
AdaBase.Driver.Base.[DB].trait_client_info ()

This is a connection attribute. It returns a string containing additional information about the the database client, such as the client library version number.

with Ada.Text_IO;
with Ada.Exceptions;
with AdaBase;
with Connect;
with GNAT.Traceback.Symbolic;

procedure Traits is

   package SYM renames GNAT.Traceback.Symbolic;
   package TIO renames Ada.Text_IO;
   package CON renames Connect;
   package EX  renames Ada.Exceptions;

   --  Database_Driver renames specific driver using subtype

   procedure display_versions (driver : CON.Database_Driver);
   procedure display_traits   (driver : CON.Database_Driver);

   procedure display_versions (driver : CON.Database_Driver) is
   begin
      TIO.Put_Line ("   client info: " & driver.trait_client_info);
      TIO.Put_Line ("client version: " & driver.trait_client_version);
      TIO.Put_Line ("   server info: " & driver.trait_server_info);
      TIO.Put_Line ("server version: " & driver.trait_server_version);
      TIO.Put_Line ("        driver: " & driver.trait_driver);
   end display_versions;

   procedure display_traits (driver : CON.Database_Driver) is
   begin
      TIO.Put_Line ("");
      TIO.Put_Line ("    autocommit: " & driver.trait_autocommit'Img);
      TIO.Put_Line ("   column case: " & driver.trait_column_case'Img);
      TIO.Put_Line ("    error_mode: " & driver.trait_error_mode'Img);
      TIO.Put_Line ("     blob_size: " & driver.trait_max_blob_size'Img);
      TIO.Put_Line (" multiquery on: " & driver.trait_multiquery_enabled'Img);
      TIO.Put_Line ("      encoding: " & driver.trait_character_set);
   end display_traits;

begin

   CON.connect_database;

   display_versions (driver => CON.DR);
   display_traits   (driver => CON.DR);

   CON.DR.disconnect;

   CON.DR.set_trait_autocommit    (trait => True);
   CON.DR.set_trait_column_case   (trait => AdaBase.upper_case);
   CON.DR.set_trait_error_mode    (trait => AdaBase.silent);
   CON.DR.set_trait_max_blob_size (trait => 2 ** 16);

   CON.DR.set_trait_multiquery_enabled (True);
   CON.DR.set_trait_character_set ("");

   CON.connect_database;
   display_traits   (driver => CON.DR);
   CON.DR.disconnect;

exception
   when E : others =>
      TIO.Put_Line ("");
      TIO.Put_Line ("exception name: " & EX.Exception_Name (E));
      TIO.Put_Line ("exception msg : " & EX.Exception_Message (E));
      TIO.Put_Line ("Traceback:");
      TIO.Put_Line (SYM.Symbolic_Traceback (E));

end Traits;

Example code: testcases/traits/traits.adb


   client info: 5.6.30
client version: 5.06.30
   server info: 5.6.27
server version: 5.06.27
        driver: MySQL 5.5+ native driver

    autocommit: FALSE
   column case: NATURAL_CASE
    error_mode: WARNING
     blob_size:  4096
 multiquery on: FALSE
      encoding: UTF8

    autocommit: TRUE
   column case: UPPER_CASE
    error_mode: SILENT
     blob_size:  65536
 multiquery on: TRUE
      encoding: LATIN1

Output using the MySQL driver


   client info: 2016-05-18 10:57:30 fc49f556e48970561d7ab6a2f24fdd7d9eb81ff2
client version: 3.13.0
   server info: Not applicable
server version: Not applicable
        driver: SQLite3 native driver

    autocommit: FALSE
   column case: NATURAL_CASE
    error_mode: WARNING
     blob_size:  4096
 multiquery on: FALSE
      encoding: UTF-8

    autocommit: TRUE
   column case: UPPER_CASE
    error_mode: SILENT
     blob_size:  65536
 multiquery on: TRUE
      encoding: UTF-8

Output using the SQLite driver


   client info: 9.05.03
client version: 9.05.03
   server info: Protocol 3.0
server version: 9.05.02
        driver: PostgreSQL 9.1+ native driver

    autocommit: FALSE
   column case: NATURAL_CASE
    error_mode: WARNING
     blob_size:  4096
 multiquery on: FALSE
      encoding: UTF8

    autocommit: TRUE
   column case: UPPER_CASE
    error_mode: SILENT
     blob_size:  65536
 multiquery on: TRUE
      encoding: UTF8

Output using the PostgreSQL driver


[DB] is "MySQL.MySQL_Driver", "PostgreSQL.PostgreSQL_Driver", or "SQLite.SQLite_Driver"

See Also