Comments - About MariaDB Connector/J

8 years, 2 months ago Diego Dupin

Hi, If performance_schema variable is activated, in Table performance_schema.session_connect_attrs, for each connection, you will have :

  • _client_name (example : MariaDB connector/J)
  • _client_version ( 1.5.4-SNAPSHOT)
  • _os (example : Windows 10)
  • _pid (example : 1636)
  • _thread (example : 13)
  • _java_vendor (example : Oracle Corporation)
  • _java_version (example : 1.8.0_91)

You can add specific information using option "connectionAttributes"

 
8 years, 2 months ago Diego Dupin

Sorry, updating the answer delete your comment. New version 1.5.4, Connection.setClientInfo() permit 3 differents Session-Specific Client Information :

  • ApplicationName
  • ClientUser
  • ClientHostname

This without having performance_schema variable activated.

 
8 years, 2 months ago Meirav Rath

Hi again, When will version 1.5.4 be released?

 
8 years, 2 months ago Diego Dupin

version 1.5.4 is available on maven central or will be available on site download in a few hours.

 
8 years, 2 months ago Meirav Rath

Great! So, I have a MariaDB 10.1.14 and the session_connect_attrs table does not have these three new parameters, and I create a short javascript that uses the new connector to make a short connection, make a simple select and then logout, what will happen? I tried to add new variables to this table but my user didn't have the permission to do it, nor did the root user. Obviously, I switched on the performance_schema.

 
8 years, 2 months ago Diego Dupin

I may have not been clear.

There is in fact 2 differents way to achieve that : standard JDBC : using connection , you can add some specific informations:

Properties properties = new Properties();
properties.setProperty("ApplicationName", "your application");
properties.setProperty("ClientUser", "your user");
properties.setProperty("ClientHostname", "myhost");

connection.setClientInfo(properties); and so after that, you will be able to retrieve those informations : String currentHost = connection.getClientInfo("myhost");

other solution is the first explain : If performance_schema variable is activated on server, in Table performance_schema.session_connect_attrs, for each connection, you will have :

  • _client_name (example : MariaDB connector/J)
  • _client_version ( 1.5.4-SNAPSHOT)
  • _os (example : Windows 10)
  • _pid (example : 1636)
  • _thread (example : 13)
  • _java_vendor (example : Oracle Corporation)
  • _java_version (example : 1.8.0_91)

You can add specific information using option "connectionAttributes" . Example connecting with url "jdbc:mariadb:localhost/db?user=xxx&connectionAttributes=key1:value1,key2,value2"

you will have then have 2 additionnals informations :

  • key1 with value "value1"
  • key2 with value "value2"
 
8 years, 2 months ago Meirav Rath

It works great, thank you so mcuh for the help and for all the fast responses!

 
8 years, 2 months ago Meirav Rath

Excellent, thanks!

 
Content reproduced on this site is the property of its respective owners, and this content is not reviewed in advance by MariaDB. The views, information and opinions expressed by this content do not necessarily represent those of MariaDB or any other party.