Skip to content

Commit f8066a7

Browse files
committed
WL#12786: Single include header for JDBC API
1 parent 2c322e6 commit f8066a7

File tree

7 files changed

+108
-15
lines changed

7 files changed

+108
-15
lines changed

CMakeLists.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -558,6 +558,10 @@ if(WITH_JDBC)
558558

559559
add_executable(try_jdbc EXCLUDE_FROM_ALL try_jdbc.cc)
560560
target_link_libraries(try_jdbc connector-jdbc)
561+
target_include_directories(try_jdbc
562+
PRIVATE "${PROJECT_BINARY_DIR}/include/mysql"
563+
PRIVATE "${PROJECT_BINARY_DIR}/include/jdbc/cppconn"
564+
)
561565

562566
endif()
563567

doc/jdbc_ref.txt

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -26,17 +26,11 @@ and reads the result from the server. The source file can be found in
2626
testapp/jdbc_test.cc in the source distribution of Connector/C++ 8.0.
2727
See @ref usage for instructions on how to build the sample code.
2828

29-
Each program which uses the legacy C++ API has to include the following
30-
headers:
29+
Each program which uses the legacy C++ API has to include this header:
3130

3231
@dontinclude jdbc_test.cc
33-
@skip #include <jdbc/mysql_connection.h>
34-
@until #include <jdbc/mysql_driver.h>
35-
36-
These headers are needed for using the `ResultSet` and `Statement` classes:
37-
38-
@skip #include <jdbc/cppconn/resultset.h>
39-
@until #include <jdbc/cppconn/statement.h>
32+
@skip #include <mysql/jdbc.h>
33+
@until #include <mysql/jdbc.h>
4034

4135
Define the credentials for connecting, process command line parameters and
4236
other housekeeping:

include/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ endif()
4747

4848
setup_headers(${CMAKE_CURRENT_SOURCE_DIR})
4949

50-
50+
add_headers_dir(mysql)
5151
add_headers_dir(mysqlx)
5252

5353
#

include/mysql/CMakeLists.txt

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
# Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved.
2+
#
3+
# This program is free software; you can redistribute it and/or modify
4+
# it under the terms of the GNU General Public License, version 2.0, as
5+
# published by the Free Software Foundation.
6+
#
7+
# This program is also distributed with certain software (including
8+
# but not limited to OpenSSL) that is licensed under separate terms,
9+
# as designated in a particular file or component or in included license
10+
# documentation. The authors of MySQL hereby grant you an
11+
# additional permission to link the program and your derivative works
12+
# with the separately licensed software that they have included with
13+
# MySQL.
14+
#
15+
# Without limiting anything contained in the foregoing, this file,
16+
# which is part of MySQL Connector/C++, is also subject to the
17+
# Universal FOSS Exception, version 1.0, a copy of which can be found at
18+
# http://oss.oracle.com/licenses/universal-foss-exception.
19+
#
20+
# This program is distributed in the hope that it will be useful, but
21+
# WITHOUT ANY WARRANTY; without even the implied warranty of
22+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
23+
# See the GNU General Public License, version 2.0, for more details.
24+
#
25+
# You should have received a copy of the GNU General Public License
26+
# along with this program; if not, write to the Free Software Foundation, Inc.,
27+
# 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
28+
29+
30+
#
31+
# MySQL Connector/C++ Public Headers
32+
#
33+
# see headers.cmake for explanations how project's public
34+
# headers are declared and processed.
35+
#
36+
37+
include(headers)
38+
39+
SET(headers jdbc.h)
40+
41+
# TODO: Make it work one beautiful day...
42+
#check_headers(${headers})
43+
#ADD_HEADERS(${headers})
44+
#ADD_HEADER_CHECKS()
45+
46+
INSTALL(FILES ${headers} DESTINATION ${INSTALL_INCLUDE_DIR}/mysql COMPONENT JDBCDev)
47+
48+
49+

include/mysql/jdbc.h

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
/*
2+
* Copyright (c) 2018, 2018, Oracle and/or its affiliates. All rights reserved.
3+
*
4+
* This program is free software; you can redistribute it and/or modify
5+
* it under the terms of the GNU General Public License, version 2.0, as
6+
* published by the Free Software Foundation.
7+
*
8+
* This program is also distributed with certain software (including
9+
* but not limited to OpenSSL) that is licensed under separate terms,
10+
* as designated in a particular file or component or in included license
11+
* documentation. The authors of MySQL hereby grant you an
12+
* additional permission to link the program and your derivative works
13+
* with the separately licensed software that they have included with
14+
* MySQL.
15+
*
16+
* Without limiting anything contained in the foregoing, this file,
17+
* which is part of MySQL Connector/C++, is also subject to the
18+
* Universal FOSS Exception, version 1.0, a copy of which can be found at
19+
* http://oss.oracle.com/licenses/universal-foss-exception.
20+
*
21+
* This program is distributed in the hope that it will be useful, but
22+
* WITHOUT ANY WARRANTY; without even the implied warranty of
23+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
24+
* See the GNU General Public License, version 2.0, for more details.
25+
*
26+
* You should have received a copy of the GNU General Public License
27+
* along with this program; if not, write to the Free Software Foundation, Inc.,
28+
* 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
29+
*/
30+
31+
#include "../jdbc/mysql_connection.h"
32+
#include "../jdbc/mysql_driver.h"
33+
#include "../jdbc/mysql_error.h"
34+
#include "../jdbc/cppconn/build_config.h"
35+
#include "../jdbc/cppconn/config.h"
36+
#include "../jdbc/cppconn/connection.h"
37+
#include "../jdbc/cppconn/datatype.h"
38+
#include "../jdbc/cppconn/driver.h"
39+
#include "../jdbc/cppconn/exception.h"
40+
#include "../jdbc/cppconn/metadata.h"
41+
#include "../jdbc/cppconn/parameter_metadata.h"
42+
#include "../jdbc/cppconn/prepared_statement.h"
43+
#include "../jdbc/cppconn/resultset.h"
44+
#include "../jdbc/cppconn/resultset_metadata.h"
45+
#include "../jdbc/cppconn/statement.h"
46+
#include "../jdbc/cppconn/sqlstring.h"
47+
#include "../jdbc/cppconn/warning.h"
48+
#include "../jdbc/cppconn/version_info.h"
49+
#include "../jdbc/cppconn/variant.h"

testapp/jdbc_test.cc

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,10 +48,7 @@
4848

4949
#include <boost/scoped_ptr.hpp>
5050

51-
#include <jdbc/mysql_connection.h>
52-
#include <jdbc/mysql_driver.h>
53-
#include <jdbc/cppconn/resultset.h>
54-
#include <jdbc/cppconn/statement.h>
51+
#include <mysql/jdbc.h>
5552

5653
#define DEFAULT_URI "tcp://127.0.0.1"
5754
#define EXAMPLE_USER "root"

try_jdbc.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
*/
3030

3131
#include <iostream>
32-
#include <jdbc/mysql_driver.h>
32+
#include <mysql/jdbc.h>
3333

3434

3535
using ::std::cout;

0 commit comments

Comments
 (0)