I want to compile this code with the CMakeList:
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
Connection conn = null;
try {
conn =
DriverManager.getConnection("jdbc:mysql://localhost/test?" +
"user=root&password=wielj12903");
} catch (SQLException ex) {
System.out.println("SQLException: " + ex.getMessage());
System.out.println("SQLState: " + ex.getSQLState());
System.out.println("VendorError: " + ex.getErrorCode());
But when I do this with this CMake-Configuration:
cmake_minimum_required(VERSION 3.5)
project(hello_java LANGUAGES Java)
find_package(Java 1.8 REQUIRED COMPONENTS Development)
file(GLOB_RECURSE SOURCES "src/*.java")
add_jar(name ${SOURCES} ENTRY_POINT Main)
I get the Error that the Connection has no suitable driver
No suitable driver found for jdbc:mysql://localhost/test/user=root&password=wielj12903
But when I compile this Code with the javac-Compiler then everything goes right and it works.
What should i configure in my CMakeList?
Best greetings and thank you for your answer