用于MySQL JDBC的CMakeList

时间:2018-04-04 16:35:41

标签: java mysql jdbc cmake

我想用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());

但是当我使用这个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)

我得到Connection没有合适的驱动程序的错误

No suitable driver found for jdbc:mysql://localhost/test/user=root&password=wielj12903

但是当我用javac-Compiler编译这个代码时,一切正常并且它可以工作。

我应该在我的CMakeList中配置什么?

致以最诚挚的问候,谢谢你的回答

0 个答案:

没有答案