[CONCPP-100] Exception thrown inside sql::Driver->connect Created: 2022-05-20  Updated: 2022-05-25  Resolved: 2022-05-24

Status: Closed
Project: MariaDB Connector/C++
Component/s: General
Affects Version/s: 1.0.1
Fix Version/s: N/A

Type: Bug Priority: Major
Reporter: leo Cluzel Assignee: Lawrin Novitsky
Resolution: Won't Fix Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

Windows 10
Visual Studio 2019



 Description   

I am trying to connect to my MariaDB instance through C++ code. Here is the code which I got from here (obviously changed the ip and credentials) : https://mariadb.com/docs/clients/mariadb-connectors/connector-cpp/connect/#connector-cpp-connection-methods-driver

It throws the following exception at the "Establish Connection":

Exception thrown: read access violation. other.theString._Mypair._Myval2 was 0xFFFFFFFFFFFFFFEF.
??
// Includes
#include <iostream>
#include <mariadb/conncpp.hpp>

// Main Process
int main(int argc, char **argv)
{
try
{
// Instantiate Driver
sql::Driver* driver = sql::mariadb::get_driver_instance();

// Configure Connection
// The URL or TCP connection string format is
// ``jdbc:mariadb://host:port/database``.
sql::SQLString url("jdbc:mariadb://192.0.2.1:3306/test");

// Use a properties map for the user name and password
//The ``useTls`` option enables TLS
//The ``tlsCA`` option specifies path to a PEM file that contains a X509 certificate for trusted Certificate Authorities (CAs).
sql::Properties properties({

{"user", "db_user"}

,

{"password", "db_user_password"}

,

{"useTls", "true"}

,

{"tlsCA", "tls-ca-root.pem"}

});

// Establish Connection
// Use a smart pointer for extra safety
std::unique_ptr<sql::Connection> conn(driver->connect(url, properties));

// Use Connection
// ...

// Close Connection
conn->close();
}

// Catch Exceptions
catch (sql::SQLException& e)

{ std::cerr << "Error Connecting to MariaDB Platform: " << e.what() << std::endl; // Exit (Failed) return 1; }

// Exit (Success)
return 0;
}??

I meet this error for 32 and 64 bits



 Comments   
Comment by Lawrin Novitsky [ 2022-05-20 ]

Thank you for your report. Is it like you are building your test program as Debug and link against our release binaries? Then that is a known issue, that is solved in 1.1 branch(not stable yet). Workarounds could be either building Release/RelWithDebInfo or building own connector binaries from source code.

Comment by Lawrin Novitsky [ 2022-05-24 ]

I'm closing it since you have not answered so far, and I'm almost sure it's the known issue, that we won't fix in the 1.0, and it is fixed in 1.1
You can always re-open it if you think it's different from what I described in my previous comment

Comment by leo Cluzel [ 2022-05-25 ]

Sorry for the late response, after testing you were right, it works when building in Release mode.

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