[CONJ-558] JDBC driver adds extra .0 to DOUBLEs that MySQL driver doesn't Created: 2017-12-15  Updated: 2017-12-18  Resolved: 2017-12-18

Status: Closed
Project: MariaDB Connector/J
Component/s: JDBC 4.2 compatibility
Affects Version/s: 2.2.0, 1.6.3
Fix Version/s: 2.2.1, 1.7.1

Type: Bug Priority: Major
Reporter: Robert Dyas Assignee: Diego Dupin
Resolution: Fixed Votes: 0
Labels: None
Environment:

centOS7



 Description   

I have a table that stores DOUBLE values. Frequently these are non-decimal values.

When I issue the following query via Workbench:

select Order_Total from Orders

Workbench gives me the expected results (importantly, so does the MySQL JDBC driver when connecting to a MySQL 5.6 database):

1031
20
558
1600
626

When I do the same via Connector/J to a MariaDB 10.1.29 database the string representation of the number via getString() adds a trailing .0 as follows:

1031.0
20.0
558.0
1600.0
626.0

I thought at first it might be a Connector/J or Mariadb server setting, but I can't find anything, so looks like incompatible behavior.



 Comments   
Comment by Diego Dupin [ 2017-12-18 ]

Right, and this is inconsistent using option "useServerPrepStmts" that will not return the additional ".0".
(That concerns FLOAT type the same way)

Comment by Diego Dupin [ 2017-12-18 ]

correction available in snapshot release :

<repositories>
    <repository>
        <id>sonatype-nexus-snapshots</id>
        <name>Sonatype Nexus Snapshots</name>
        <url>https://oss.sonatype.org/content/repositories/snapshots</url>
    </repository>
</repositories>
 
<dependencies>
    <dependency>
        <groupId>org.mariadb.jdbc</groupId>
        <artifactId>mariadb-java-client</artifactId>
        <version>2.2.1-SNAPSHOT</version>
    </dependency>
</dependencies>

Comment by Robert Dyas [ 2017-12-18 ]

Great! Just tried it, and working as expected. Thank you.

New Issue: I'll make a seperate thread if its an issue and not a misunderstanding:
when i switched from 1.6.3 to 2.2.1 I get the error:

SSL hostname verification failed : IPv4 host "35.224.113.70" doesn't correspond to certificate CN "si-mariadb-shared1-v1.parasql.com"

My connect string includes the following and was connecting to a specific IP address:

&useSSL=true&trustServerCertificate=false&serverSslCert= etc

That setting under 2.2.1 throws an exception and the documentation states the following:

disableSslHostnameVerification	When using ssl, the driver checks the hostname against the server's identity as presented in the server's certificate (checking alternative names or the certificate CN) to prevent man-in-the-middle attacks. This option permits deactivating this validation. Hostname verification is disabled when the trustServerCertificate option is set
Default: false. Since 2.1.0

It is unclear to me if set means set to true or false. It would seem that since I am connecting to an IP and verifying the CA that I don't need to verify a potentially non-existant host name.

Comment by Diego Dupin [ 2017-12-18 ]

That's a because driver ensures hostname verification.
SSL certificate must have a SAN (Subject Alternative Name) that corresponds to the current host used for connection (RFC 6125)
Or if no SAN are present (not recommended for more than 10 years), Driver use CN name to check hostname (RFC 2818).

If 35.224.113.70 correspond to si-mariadb-shared1-v1.parasql.com, just use this DNS name to connect. If not, the best solution would be to create an SSL certificate with correct SAN values.

This validation can be avoided setting option "disableSslHostnameVerification" to true.

Generated at Thu Feb 08 03:16:39 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.