Search code examples
javamysqlconnector-j

Read Value of MySQL connection string property 'allowNanAndInf'


MySQL has a connection string flag called allowNanAndInf. I have a java webapp with a connection string containing allowNanAndInf=true. The allowNanAndInf connection string flag tells MySQL to permit NaN values in double fields.

I changed the file that should control the connection string and rebooted my server, but MySQL ConnectorJ still will not permit NaN values in double fields.

As a debugging step, I would like to printout the current value of allowNanAndInf on my datasource. I am using hibernate, but I can't seem to find any documentation about how to printout the current value of a connection string property for a JDBC connection. Any ideas? How can I printout the current value of the allowNanAndInf connection string flag for a connection?


Solution

  • Your should debug your datasource connection object, remember that Hibernate receives a connection to deal with, I dont think that Hibernate has any utility to debug datasources, for debugging purposes you should try to use DriverPropertyInfo collection from your Driver class.

    Something like this

    DriverPropertyInfo[] attrs = driver.getPropertyInfo("jdbc:mysql://localhost/mydb", props);
    

    You can find a great example here

    http://www.java2s.com/Code/Java/Database-SQL-JDBC/GetDriverPropertyInfo.htm