6 |
7 | # OceanBase Client for Java
8 | OceanBase Client for Java is a JDBC 4.2 compatible driver, used to connect applications developed in Java to OceanBase Database Server.
9 |
10 | # Compatibility
11 | ## Server Compatibility
12 | OceanBase Client for Java is compatible with all OceanBase Database Server versions.
13 | ## Java Compatibility
14 | OceanBase Client for Java is developed based on Java 8, please confirm your Java version.
15 | ## Obtaining the driver
16 | The driver (jar) can be downloaded from maven:
17 | ```script
18 |
19 | com.oceanbase
20 | oceanbase-client
21 | 2.4.14
22 |
23 | ```
24 | ## Building from source
25 | ```script
26 | mvn clean package -DskipTests
27 | ```
28 | ## Documentation
29 | For more information about this project, please refer to:
30 | * [About OceanBase](https://www.oceanbase.com/)
31 | * [OceanBase documents](https://www.oceanbase.com/docs)
32 | ## License
33 |
34 | Distributed under the LGPL License. See `LICENSE` for more information.
35 | ## Acknowledgement
36 |
37 | OceanBase Connector/J was ported from MariaDB Connector/J with some OceanBase protocol support and improvement. Thanks to the MariaDB for opening up such a great Database Connector implementation.
38 |
--------------------------------------------------------------------------------
/aci.yml:
--------------------------------------------------------------------------------
1 | version: "2.0"
2 |
3 | stages:
4 | - 代码扫描
5 |
6 | jobs:
7 | 安全扫描:
8 | stage: 代码扫描
9 | component: stc
10 | inputs:
11 | tenantName: oceanbase # 使用oceanbase规则进行扫描,而不是用主站规则
12 | # checkRule:
13 | # - urgentCount = 0 && highCount = 0 # 卡点规则:高危和严重bug数均为0
14 | # - urgent = 0 && high = 0
15 |
16 | # only:
17 | # triggerType:
18 | # - tagPush
--------------------------------------------------------------------------------
/oceanbase-jdbc.release:
--------------------------------------------------------------------------------
1 | # 1. You can edit the content of this file directly , or use tools to help you verify the legality and automatically generate it , please click http=//aliwing.alibaba-inc.com/apprelease/home.htm
2 | # 2. For more about the specifications and conventions of Release files , please click http=//docs.alibaba-inc.com/pages/viewpage.action?pageId=252891532
3 |
4 | code.language=java
5 |
6 | baseline.jdk=jdk-1.8.0_40
7 |
8 | build.tools.maven=maven3.2.5
9 |
10 | build.tools.maven.settings=tao
11 |
12 | build.output=target
13 |
14 |
--------------------------------------------------------------------------------
/src/main/java/com/alipay/oceanbase/jdbc/Driver.java:
--------------------------------------------------------------------------------
1 | /*
2 | *
3 | * OceanBase Client for Java
4 | *
5 | * Copyright (c) 2021 OceanBase.
6 | *
7 | * This library is free software; you can redistribute it and/or modify it under
8 | * the terms of the GNU Lesser General Public License as published by the Free
9 | * Software Foundation; either version 2.1 of the License, or (at your option)
10 | * any later version.
11 | *
12 | * This library is distributed in the hope that it will be useful, but
13 | * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
14 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
15 | * for more details.
16 | *
17 | * Copyright (c) 2009-2011, Marcus Eriksson
18 | *
19 | * Redistribution and use in source and binary forms, with or without modification,
20 | * are permitted provided that the following conditions are met:
21 | * Redistributions of source code must retain the above copyright notice, this list
22 | * of conditions and the following disclaimer.
23 | *
24 | * Redistributions in binary form must reproduce the above copyright notice, this
25 | * list of conditions and the following disclaimer in the documentation and/or
26 | * other materials provided with the distribution.
27 | *
28 | * Neither the name of the driver nor the names of its contributors may not be
29 | * used to endorse or promote products derived from this software without specific
30 | * prior written permission.
31 | *
32 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
33 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
34 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
35 | * IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
36 | * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
37 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
38 | * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
39 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
40 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
41 | * OF SUCH DAMAGE.
42 | *
43 | */
44 | package com.alipay.oceanbase.jdbc;
45 |
46 | import java.sql.*;
47 |
48 | import com.oceanbase.jdbc.internal.util.DeRegister;
49 |
50 | public class Driver extends com.oceanbase.jdbc.Driver {
51 |
52 | static {
53 | try {
54 | DriverManager.registerDriver(new com.oceanbase.jdbc.Driver(), new DeRegister());
55 | } catch (SQLException e) {
56 | throw new RuntimeException("Could not register driver", e);
57 | }
58 | }
59 |
60 | public Driver() throws SQLException {
61 | // Required for Class.forName().newInstance()
62 | }
63 | }
--------------------------------------------------------------------------------
/src/main/java/com/alipay/oceanbase/obproxy/mysql/jdbc/Driver.java:
--------------------------------------------------------------------------------
1 | /*
2 | *
3 | * OceanBase Client for Java
4 | *
5 | * Copyright (c) 2021 OceanBase.
6 | *
7 | * This library is free software; you can redistribute it and/or modify it under
8 | * the terms of the GNU Lesser General Public License as published by the Free
9 | * Software Foundation; either version 2.1 of the License, or (at your option)
10 | * any later version.
11 | *
12 | * This library is distributed in the hope that it will be useful, but
13 | * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
14 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
15 | * for more details.
16 | *
17 | * Copyright (c) 2009-2011, Marcus Eriksson
18 | *
19 | * Redistribution and use in source and binary forms, with or without modification,
20 | * are permitted provided that the following conditions are met:
21 | * Redistributions of source code must retain the above copyright notice, this list
22 | * of conditions and the following disclaimer.
23 | *
24 | * Redistributions in binary form must reproduce the above copyright notice, this
25 | * list of conditions and the following disclaimer in the documentation and/or
26 | * other materials provided with the distribution.
27 | *
28 | * Neither the name of the driver nor the names of its contributors may not be
29 | * used to endorse or promote products derived from this software without specific
30 | * prior written permission.
31 | *
32 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
33 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
34 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
35 | * IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
36 | * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
37 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
38 | * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
39 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
40 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
41 | * OF SUCH DAMAGE.
42 | *
43 | */
44 | package com.alipay.oceanbase.obproxy.mysql.jdbc;
45 |
46 | import java.sql.DriverManager;
47 | import java.sql.SQLException;
48 |
49 | import com.oceanbase.jdbc.internal.util.DeRegister;
50 |
51 | public class Driver extends com.oceanbase.jdbc.Driver {
52 |
53 | static {
54 | try {
55 | DriverManager.registerDriver(new com.oceanbase.jdbc.Driver(), new DeRegister());
56 | } catch (SQLException e) {
57 | throw new RuntimeException("Could not register driver", e);
58 | }
59 | }
60 |
61 | public Driver() throws SQLException {
62 | // Required for Class.forName().newInstance()
63 | }
64 | }
65 |
--------------------------------------------------------------------------------
/src/main/java/com/oceanbase/jdbc/ConnectionImpl.java:
--------------------------------------------------------------------------------
1 | /**
2 | * OceanBase Client for Java
3 | *
4 | * Copyright (c) 2012-2014 Monty Program Ab.
5 | * Copyright (c) 2015-2020 MariaDB Corporation Ab.
6 | * Copyright (c) 2021 OceanBase.
7 | *
8 | * This library is free software; you can redistribute it and/or modify it under
9 | * the terms of the GNU Lesser General Public License as published by the Free
10 | * Software Foundation; either version 2.1 of the License, or (at your option)
11 | * any later version.
12 | *
13 | * This library is distributed in the hope that it will be useful, but
14 | * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
15 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
16 | * for more details.
17 | *
18 | * You should have received a copy of the GNU Lesser General Public License along
19 | * with this library; if not, write to Monty Program Ab info@montyprogram.com.
20 | *
21 | * This particular MariaDB Client for Java file is work
22 | * derived from a Drizzle-JDBC. Drizzle-JDBC file which is covered by subject to
23 | * the following copyright and notice provisions:
24 | *
25 | * Copyright (c) 2009-2011, Marcus Eriksson
26 | *
27 | * Redistribution and use in source and binary forms, with or without modification,
28 | * are permitted provided that the following conditions are met:
29 | * Redistributions of source code must retain the above copyright notice, this list
30 | * of conditions and the following disclaimer.
31 | *
32 | * Redistributions in binary form must reproduce the above copyright notice, this
33 | * list of conditions and the following disclaimer in the documentation and/or
34 | * other materials provided with the distribution.
35 | *
36 | * Neither the name of the driver nor the names of its contributors may not be
37 | * used to endorse or promote products derived from this software without specific
38 | * prior written permission.
39 | *
40 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
41 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
42 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
43 | * IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
44 | * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
45 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
46 | * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
47 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
48 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
49 | * OF SUCH DAMAGE.
50 | */
51 | package com.oceanbase.jdbc;
52 |
53 | /**
54 | * Compatible with jdbc1.X interface class, mainly used to add oracle mode interfaces
55 | */
56 | public interface ConnectionImpl extends JDBC4MySQLConnection {
57 |
58 | }
59 |
--------------------------------------------------------------------------------
/src/main/java/com/oceanbase/jdbc/ExceptionInterceptor.java:
--------------------------------------------------------------------------------
1 | /**
2 | * OceanBase Client for Java
3 | *
4 | * Copyright (c) 2012-2014 Monty Program Ab.
5 | * Copyright (c) 2015-2020 MariaDB Corporation Ab.
6 | * Copyright (c) 2021 OceanBase.
7 | *
8 | * This library is free software; you can redistribute it and/or modify it under
9 | * the terms of the GNU Lesser General Public License as published by the Free
10 | * Software Foundation; either version 2.1 of the License, or (at your option)
11 | * any later version.
12 | *
13 | * This library is distributed in the hope that it will be useful, but
14 | * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
15 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
16 | * for more details.
17 | *
18 | * You should have received a copy of the GNU Lesser General Public License along
19 | * with this library; if not, write to Monty Program Ab info@montyprogram.com.
20 | *
21 | * This particular MariaDB Client for Java file is work
22 | * derived from a Drizzle-JDBC. Drizzle-JDBC file which is covered by subject to
23 | * the following copyright and notice provisions:
24 | *
25 | * Copyright (c) 2009-2011, Marcus Eriksson
26 | *
27 | * Redistribution and use in source and binary forms, with or without modification,
28 | * are permitted provided that the following conditions are met:
29 | * Redistributions of source code must retain the above copyright notice, this list
30 | * of conditions and the following disclaimer.
31 | *
32 | * Redistributions in binary form must reproduce the above copyright notice, this
33 | * list of conditions and the following disclaimer in the documentation and/or
34 | * other materials provided with the distribution.
35 | *
36 | * Neither the name of the driver nor the names of its contributors may not be
37 | * used to endorse or promote products derived from this software without specific
38 | * prior written permission.
39 | *
40 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
41 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
42 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
43 | * IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
44 | * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
45 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
46 | * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
47 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
48 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
49 | * OF SUCH DAMAGE.
50 | */
51 | package com.oceanbase.jdbc;
52 |
53 | import java.security.cert.Extension;
54 | import java.sql.Connection;
55 | import java.sql.SQLException;
56 |
57 | public interface ExceptionInterceptor extends Extension {
58 | SQLException interceptException(SQLException sqlEx, Connection conn);
59 | }
60 |
--------------------------------------------------------------------------------
/src/main/java/com/oceanbase/jdbc/JDBC4MySQLConnection.java:
--------------------------------------------------------------------------------
1 | /**
2 | * OceanBase Client for Java
3 | *
4 | * Copyright (c) 2012-2014 Monty Program Ab.
5 | * Copyright (c) 2015-2020 MariaDB Corporation Ab.
6 | * Copyright (c) 2021 OceanBase.
7 | *
8 | * This library is free software; you can redistribute it and/or modify it under
9 | * the terms of the GNU Lesser General Public License as published by the Free
10 | * Software Foundation; either version 2.1 of the License, or (at your option)
11 | * any later version.
12 | *
13 | * This library is distributed in the hope that it will be useful, but
14 | * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
15 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
16 | * for more details.
17 | *
18 | * You should have received a copy of the GNU Lesser General Public License along
19 | * with this library; if not, write to Monty Program Ab info@montyprogram.com.
20 | *
21 | * This particular MariaDB Client for Java file is work
22 | * derived from a Drizzle-JDBC. Drizzle-JDBC file which is covered by subject to
23 | * the following copyright and notice provisions:
24 | *
25 | * Copyright (c) 2009-2011, Marcus Eriksson
26 | *
27 | * Redistribution and use in source and binary forms, with or without modification,
28 | * are permitted provided that the following conditions are met:
29 | * Redistributions of source code must retain the above copyright notice, this list
30 | * of conditions and the following disclaimer.
31 | *
32 | * Redistributions in binary form must reproduce the above copyright notice, this
33 | * list of conditions and the following disclaimer in the documentation and/or
34 | * other materials provided with the distribution.
35 | *
36 | * Neither the name of the driver nor the names of its contributors may not be
37 | * used to endorse or promote products derived from this software without specific
38 | * prior written permission.
39 | *
40 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
41 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
42 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
43 | * IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
44 | * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
45 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
46 | * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
47 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
48 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
49 | * OF SUCH DAMAGE.
50 | */
51 | package com.oceanbase.jdbc;
52 |
53 | public interface JDBC4MySQLConnection extends ObConnection {
54 | }
55 |
--------------------------------------------------------------------------------
/src/main/java/com/oceanbase/jdbc/JDBC4NClob.java:
--------------------------------------------------------------------------------
1 | /**
2 | * OceanBase Client for Java
3 | *
4 | * Copyright (c) 2012-2014 Monty Program Ab.
5 | * Copyright (c) 2015-2020 MariaDB Corporation Ab.
6 | * Copyright (c) 2021 OceanBase.
7 | *
8 | * This library is free software; you can redistribute it and/or modify it under
9 | * the terms of the GNU Lesser General Public License as published by the Free
10 | * Software Foundation; either version 2.1 of the License, or (at your option)
11 | * any later version.
12 | *
13 | * This library is distributed in the hope that it will be useful, but
14 | * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
15 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
16 | * for more details.
17 | *
18 | * You should have received a copy of the GNU Lesser General Public License along
19 | * with this library; if not, write to Monty Program Ab info@montyprogram.com.
20 | *
21 | * This particular MariaDB Client for Java file is work
22 | * derived from a Drizzle-JDBC. Drizzle-JDBC file which is covered by subject to
23 | * the following copyright and notice provisions:
24 | *
25 | * Copyright (c) 2009-2011, Marcus Eriksson
26 | *
27 | * Redistribution and use in source and binary forms, with or without modification,
28 | * are permitted provided that the following conditions are met:
29 | * Redistributions of source code must retain the above copyright notice, this list
30 | * of conditions and the following disclaimer.
31 | *
32 | * Redistributions in binary form must reproduce the above copyright notice, this
33 | * list of conditions and the following disclaimer in the documentation and/or
34 | * other materials provided with the distribution.
35 | *
36 | * Neither the name of the driver nor the names of its contributors may not be
37 | * used to endorse or promote products derived from this software without specific
38 | * prior written permission.
39 | *
40 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
41 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
42 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
43 | * IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
44 | * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
45 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
46 | * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
47 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
48 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
49 | * OF SUCH DAMAGE.
50 | */
51 | package com.oceanbase.jdbc;
52 |
53 | import java.sql.NClob;
54 |
55 | public class JDBC4NClob extends Clob implements NClob {
56 |
57 | JDBC4NClob(String charDataInit, ExceptionInterceptor exceptionInterceptor) {
58 | super(charDataInit, exceptionInterceptor);
59 | }
60 | }
61 |
--------------------------------------------------------------------------------
/src/main/java/com/oceanbase/jdbc/LocalInfileInterceptor.java:
--------------------------------------------------------------------------------
1 | /**
2 | * OceanBase Client for Java
3 | *
4 | * Copyright (c) 2012-2014 Monty Program Ab.
5 | * Copyright (c) 2015-2020 MariaDB Corporation Ab.
6 | * Copyright (c) 2021 OceanBase.
7 | *
8 | * This library is free software; you can redistribute it and/or modify it under
9 | * the terms of the GNU Lesser General Public License as published by the Free
10 | * Software Foundation; either version 2.1 of the License, or (at your option)
11 | * any later version.
12 | *
13 | * This library is distributed in the hope that it will be useful, but
14 | * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
15 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
16 | * for more details.
17 | *
18 | * You should have received a copy of the GNU Lesser General Public License along
19 | * with this library; if not, write to Monty Program Ab info@montyprogram.com.
20 | *
21 | * This particular MariaDB Client for Java file is work
22 | * derived from a Drizzle-JDBC. Drizzle-JDBC file which is covered by subject to
23 | * the following copyright and notice provisions:
24 | *
25 | * Copyright (c) 2009-2011, Marcus Eriksson
26 | *
27 | * Redistribution and use in source and binary forms, with or without modification,
28 | * are permitted provided that the following conditions are met:
29 | * Redistributions of source code must retain the above copyright notice, this list
30 | * of conditions and the following disclaimer.
31 | *
32 | * Redistributions in binary form must reproduce the above copyright notice, this
33 | * list of conditions and the following disclaimer in the documentation and/or
34 | * other materials provided with the distribution.
35 | *
36 | * Neither the name of the driver nor the names of its contributors may not be
37 | * used to endorse or promote products derived from this software without specific
38 | * prior written permission.
39 | *
40 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
41 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
42 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
43 | * IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
44 | * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
45 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
46 | * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
47 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
48 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
49 | * OF SUCH DAMAGE.
50 | */
51 | package com.oceanbase.jdbc;
52 |
53 | public interface LocalInfileInterceptor {
54 |
55 | boolean validate(String fileName);
56 | }
57 |
--------------------------------------------------------------------------------
/src/main/java/com/oceanbase/jdbc/MysqlConnection.java:
--------------------------------------------------------------------------------
1 | /**
2 | * OceanBase Client for Java
3 | *
4 | * Copyright (c) 2012-2014 Monty Program Ab.
5 | * Copyright (c) 2015-2020 MariaDB Corporation Ab.
6 | * Copyright (c) 2021 OceanBase.
7 | *
8 | * This library is free software; you can redistribute it and/or modify it under
9 | * the terms of the GNU Lesser General Public License as published by the Free
10 | * Software Foundation; either version 2.1 of the License, or (at your option)
11 | * any later version.
12 | *
13 | * This library is distributed in the hope that it will be useful, but
14 | * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
15 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
16 | * for more details.
17 | *
18 | * You should have received a copy of the GNU Lesser General Public License along
19 | * with this library; if not, write to Monty Program Ab info@montyprogram.com.
20 | *
21 | * This particular MariaDB Client for Java file is work
22 | * derived from a Drizzle-JDBC. Drizzle-JDBC file which is covered by subject to
23 | * the following copyright and notice provisions:
24 | *
25 | * Copyright (c) 2009-2011, Marcus Eriksson
26 | *
27 | * Redistribution and use in source and binary forms, with or without modification,
28 | * are permitted provided that the following conditions are met:
29 | * Redistributions of source code must retain the above copyright notice, this list
30 | * of conditions and the following disclaimer.
31 | *
32 | * Redistributions in binary form must reproduce the above copyright notice, this
33 | * list of conditions and the following disclaimer in the documentation and/or
34 | * other materials provided with the distribution.
35 | *
36 | * Neither the name of the driver nor the names of its contributors may not be
37 | * used to endorse or promote products derived from this software without specific
38 | * prior written permission.
39 | *
40 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
41 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
42 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
43 | * IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
44 | * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
45 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
46 | * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
47 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
48 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
49 | * OF SUCH DAMAGE.
50 | */
51 | package com.oceanbase.jdbc;
52 |
53 | import java.sql.Connection;
54 |
55 | public interface MysqlConnection extends Connection {
56 | }
57 |
--------------------------------------------------------------------------------
/src/main/java/com/oceanbase/jdbc/MysqlSavepoint.java:
--------------------------------------------------------------------------------
1 | /**
2 | * OceanBase Client for Java
3 | *
4 | * Copyright (c) 2012-2014 Monty Program Ab.
5 | * Copyright (c) 2015-2020 MariaDB Corporation Ab.
6 | * Copyright (c) 2021 OceanBase.
7 | *
8 | * This library is free software; you can redistribute it and/or modify it under
9 | * the terms of the GNU Lesser General Public License as published by the Free
10 | * Software Foundation; either version 2.1 of the License, or (at your option)
11 | * any later version.
12 | *
13 | * This library is distributed in the hope that it will be useful, but
14 | * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
15 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
16 | * for more details.
17 | *
18 | * You should have received a copy of the GNU Lesser General Public License along
19 | * with this library; if not, write to Monty Program Ab info@montyprogram.com.
20 | *
21 | * This particular MariaDB Client for Java file is work
22 | * derived from a Drizzle-JDBC. Drizzle-JDBC file which is covered by subject to
23 | * the following copyright and notice provisions:
24 | *
25 | * Copyright (c) 2009-2011, Marcus Eriksson
26 | *
27 | * Redistribution and use in source and binary forms, with or without modification,
28 | * are permitted provided that the following conditions are met:
29 | * Redistributions of source code must retain the above copyright notice, this list
30 | * of conditions and the following disclaimer.
31 | *
32 | * Redistributions in binary form must reproduce the above copyright notice, this
33 | * list of conditions and the following disclaimer in the documentation and/or
34 | * other materials provided with the distribution.
35 | *
36 | * Neither the name of the driver nor the names of its contributors may not be
37 | * used to endorse or promote products derived from this software without specific
38 | * prior written permission.
39 | *
40 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
41 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
42 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
43 | * IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
44 | * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
45 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
46 | * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
47 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
48 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
49 | * OF SUCH DAMAGE.
50 | */
51 | package com.oceanbase.jdbc;
52 |
53 | public class MysqlSavepoint extends OceanBaseSavepoint {
54 | public MysqlSavepoint(String name) {
55 | super(name);
56 | }
57 | }
58 |
--------------------------------------------------------------------------------
/src/main/java/com/oceanbase/jdbc/ObArray.java:
--------------------------------------------------------------------------------
1 | /*
2 | *
3 | * OceanBase Client for Java
4 | *
5 | * Copyright (c) 2021 OceanBase.
6 | *
7 | * This library is free software; you can redistribute it and/or modify it under
8 | * the terms of the GNU Lesser General Public License as published by the Free
9 | * Software Foundation; either version 2.1 of the License, or (at your option)
10 | * any later version.
11 | *
12 | * This library is distributed in the hope that it will be useful, but
13 | * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
14 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
15 | * for more details.
16 | *
17 | * Copyright (c) 2009-2011, Marcus Eriksson
18 | *
19 | * Redistribution and use in source and binary forms, with or without modification,
20 | * are permitted provided that the following conditions are met:
21 | * Redistributions of source code must retain the above copyright notice, this list
22 | * of conditions and the following disclaimer.
23 | *
24 | * Redistributions in binary form must reproduce the above copyright notice, this
25 | * list of conditions and the following disclaimer in the documentation and/or
26 | * other materials provided with the distribution.
27 | *
28 | * Neither the name of the driver nor the names of its contributors may not be
29 | * used to endorse or promote products derived from this software without specific
30 | * prior written permission.
31 | *
32 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
33 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
34 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
35 | * IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
36 | * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
37 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
38 | * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
39 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
40 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
41 | * OF SUCH DAMAGE.
42 | *
43 | */
44 | package com.oceanbase.jdbc;
45 |
46 | import java.sql.Array;
47 | import java.sql.ResultSet;
48 | import java.sql.SQLException;
49 | import java.util.Map;
50 |
51 | public interface ObArray extends ResultSet, Array, ObComplexData {
52 | String getBaseTypeName() throws SQLException;
53 |
54 | int getBaseType() throws SQLException;
55 |
56 | Object getArray() throws SQLException;
57 |
58 | Object getArray(Map> stringClassMap) throws SQLException;
59 |
60 | Object getArray(long index, int count) throws SQLException;
61 |
62 | Object getArray(long index, int count, Map> stringClassMap)
63 | throws SQLException;
64 |
65 | ResultSet getResultSet() throws SQLException;
66 |
67 | ResultSet getResultSet(Map> stringClassMap) throws SQLException;
68 |
69 | ResultSet getResultSet(long index, int count) throws SQLException;
70 |
71 | ResultSet getResultSet(long index, int count, Map> stringClassMap)
72 | throws SQLException;
73 |
74 | void free() throws SQLException;
75 | }
76 |
--------------------------------------------------------------------------------
/src/main/java/com/oceanbase/jdbc/ObComplexData.java:
--------------------------------------------------------------------------------
1 | /*
2 | *
3 | * OceanBase Client for Java
4 | *
5 | * Copyright (c) 2021 OceanBase.
6 | *
7 | * This library is free software; you can redistribute it and/or modify it under
8 | * the terms of the GNU Lesser General Public License as published by the Free
9 | * Software Foundation; either version 2.1 of the License, or (at your option)
10 | * any later version.
11 | *
12 | * This library is distributed in the hope that it will be useful, but
13 | * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
14 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
15 | * for more details.
16 | *
17 | * Copyright (c) 2009-2011, Marcus Eriksson
18 | *
19 | * Redistribution and use in source and binary forms, with or without modification,
20 | * are permitted provided that the following conditions are met:
21 | * Redistributions of source code must retain the above copyright notice, this list
22 | * of conditions and the following disclaimer.
23 | *
24 | * Redistributions in binary form must reproduce the above copyright notice, this
25 | * list of conditions and the following disclaimer in the documentation and/or
26 | * other materials provided with the distribution.
27 | *
28 | * Neither the name of the driver nor the names of its contributors may not be
29 | * used to endorse or promote products derived from this software without specific
30 | * prior written permission.
31 | *
32 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
33 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
34 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
35 | * IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
36 | * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
37 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
38 | * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
39 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
40 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
41 | * OF SUCH DAMAGE.
42 | *
43 | */
44 | package com.oceanbase.jdbc;
45 |
46 | import com.oceanbase.jdbc.extend.datatype.ComplexDataType;
47 |
48 | public interface ObComplexData {
49 | ComplexDataType getComplexType();
50 |
51 | void setComplexType(ComplexDataType complexType);
52 |
53 | Object getAttrData(int attrIndex);
54 |
55 | Object[] getAttrData();
56 |
57 | void setAttrData(Object[] attrData);
58 |
59 | int getAttrCount();
60 |
61 | void setAttrCount(int attrCount);
62 |
63 | void addAttrData(int index, Object value);
64 | }
65 |
--------------------------------------------------------------------------------
/src/main/java/com/oceanbase/jdbc/ObConnection.java:
--------------------------------------------------------------------------------
1 | /*
2 | *
3 | * OceanBase Client for Java
4 | *
5 | * Copyright (c) 2021 OceanBase.
6 | *
7 | * This library is free software; you can redistribute it and/or modify it under
8 | * the terms of the GNU Lesser General Public License as published by the Free
9 | * Software Foundation; either version 2.1 of the License, or (at your option)
10 | * any later version.
11 | *
12 | * This library is distributed in the hope that it will be useful, but
13 | * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
14 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
15 | * for more details.
16 | *
17 | * Copyright (c) 2009-2011, Marcus Eriksson
18 | *
19 | * Redistribution and use in source and binary forms, with or without modification,
20 | * are permitted provided that the following conditions are met:
21 | * Redistributions of source code must retain the above copyright notice, this list
22 | * of conditions and the following disclaimer.
23 | *
24 | * Redistributions in binary form must reproduce the above copyright notice, this
25 | * list of conditions and the following disclaimer in the documentation and/or
26 | * other materials provided with the distribution.
27 | *
28 | * Neither the name of the driver nor the names of its contributors may not be
29 | * used to endorse or promote products derived from this software without specific
30 | * prior written permission.
31 | *
32 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
33 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
34 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
35 | * IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
36 | * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
37 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
38 | * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
39 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
40 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
41 | * OF SUCH DAMAGE.
42 | *
43 | */
44 | package com.oceanbase.jdbc;
45 |
46 | import java.sql.SQLException;
47 |
48 | public interface ObConnection extends MysqlConnection {
49 | void setSessionTimeZone(String zoneID) throws SQLException;
50 |
51 | String getSessionTimeZone();
52 |
53 | void changeUser(String userName, String newPassword) throws SQLException;
54 |
55 | void setRemarksReporting(boolean remarksReporting);
56 |
57 | boolean getRemarksReporting();
58 | }
59 |
--------------------------------------------------------------------------------
/src/main/java/com/oceanbase/jdbc/ObPrepareStatement.java:
--------------------------------------------------------------------------------
1 | /*
2 | *
3 | * OceanBase Client for Java
4 | *
5 | * Copyright (c) 2021 OceanBase.
6 | *
7 | * This library is free software; you can redistribute it and/or modify it under
8 | * the terms of the GNU Lesser General Public License as published by the Free
9 | * Software Foundation; either version 2.1 of the License, or (at your option)
10 | * any later version.
11 | *
12 | * This library is distributed in the hope that it will be useful, but
13 | * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
14 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
15 | * for more details.
16 | *
17 | * Copyright (c) 2009-2011, Marcus Eriksson
18 | *
19 | * Redistribution and use in source and binary forms, with or without modification,
20 | * are permitted provided that the following conditions are met:
21 | * Redistributions of source code must retain the above copyright notice, this list
22 | * of conditions and the following disclaimer.
23 | *
24 | * Redistributions in binary form must reproduce the above copyright notice, this
25 | * list of conditions and the following disclaimer in the documentation and/or
26 | * other materials provided with the distribution.
27 | *
28 | * Neither the name of the driver nor the names of its contributors may not be
29 | * used to endorse or promote products derived from this software without specific
30 | * prior written permission.
31 | *
32 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
33 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
34 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
35 | * IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
36 | * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
37 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
38 | * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
39 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
40 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
41 | * OF SUCH DAMAGE.
42 | *
43 | */
44 | package com.oceanbase.jdbc;
45 |
46 | import java.sql.PreparedStatement;
47 | import java.sql.Timestamp;
48 |
49 | import com.oceanbase.jdbc.extend.datatype.INTERVALDS;
50 | import com.oceanbase.jdbc.extend.datatype.INTERVALYM;
51 | import com.oceanbase.jdbc.extend.datatype.TIMESTAMPLTZ;
52 | import com.oceanbase.jdbc.extend.datatype.TIMESTAMPTZ;
53 |
54 | public interface ObPrepareStatement extends PreparedStatement {
55 | void setINTERVALDS(int parameterIndex, INTERVALDS intervalds) throws java.sql.SQLException;
56 |
57 | void setINTERVALYM(int parameterIndex, INTERVALYM intervalym) throws java.sql.SQLException;
58 |
59 | void setTIMESTAMP(int parameterIndex, Timestamp timestamp) throws java.sql.SQLException;
60 |
61 | void setTIMESTAMPLTZ(int parameterIndex, TIMESTAMPLTZ timestampltz)
62 | throws java.sql.SQLException;
63 |
64 | void setTIMESTAMPTZ(int parameterIndex, TIMESTAMPTZ timestamptz) throws java.sql.SQLException;
65 |
66 | void setFixedCHAR(int parameterIndex, String parameterStr) throws java.sql.SQLException;
67 | }
68 |
--------------------------------------------------------------------------------
/src/main/java/com/oceanbase/jdbc/ObResultSet.java:
--------------------------------------------------------------------------------
1 | /*
2 | *
3 | * OceanBase Client for Java
4 | *
5 | * Copyright (c) 2021 OceanBase.
6 | *
7 | * This library is free software; you can redistribute it and/or modify it under
8 | * the terms of the GNU Lesser General Public License as published by the Free
9 | * Software Foundation; either version 2.1 of the License, or (at your option)
10 | * any later version.
11 | *
12 | * This library is distributed in the hope that it will be useful, but
13 | * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
14 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
15 | * for more details.
16 | *
17 | * Copyright (c) 2009-2011, Marcus Eriksson
18 | *
19 | * Redistribution and use in source and binary forms, with or without modification,
20 | * are permitted provided that the following conditions are met:
21 | * Redistributions of source code must retain the above copyright notice, this list
22 | * of conditions and the following disclaimer.
23 | *
24 | * Redistributions in binary form must reproduce the above copyright notice, this
25 | * list of conditions and the following disclaimer in the documentation and/or
26 | * other materials provided with the distribution.
27 | *
28 | * Neither the name of the driver nor the names of its contributors may not be
29 | * used to endorse or promote products derived from this software without specific
30 | * prior written permission.
31 | *
32 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
33 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
34 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
35 | * IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
36 | * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
37 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
38 | * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
39 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
40 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
41 | * OF SUCH DAMAGE.
42 | *
43 | */
44 | package com.oceanbase.jdbc;
45 |
46 | import java.sql.ResultSet;
47 | import java.sql.SQLException;
48 |
49 | import com.oceanbase.jdbc.extend.datatype.*;
50 |
51 | public interface ObResultSet extends ResultSet {
52 | TIMESTAMPTZ getTIMESTAMPTZ(int columnIndex) throws SQLException;
53 |
54 | TIMESTAMPTZ getTIMESTAMPTZ(String columnName) throws SQLException;
55 |
56 | TIMESTAMPLTZ getTIMESTAMPLTZ(int columnIndex) throws SQLException;
57 |
58 | TIMESTAMPLTZ getTIMESTAMPLTZ(String columnName) throws SQLException;
59 |
60 | INTERVALYM getINTERVALYM(int columnIndex) throws SQLException;
61 |
62 | INTERVALYM getINTERVALYM(String columnName) throws SQLException;
63 |
64 | INTERVALDS getINTERVALDS(int columnIndex) throws SQLException;
65 |
66 | INTERVALDS getINTERVALDS(String columnName) throws SQLException;
67 |
68 | NUMBER getNUMBER(int columnIndex) throws SQLException;
69 |
70 | NUMBER getNUMBER(String columnName) throws SQLException;
71 | }
72 |
--------------------------------------------------------------------------------
/src/main/java/com/oceanbase/jdbc/ObStruct.java:
--------------------------------------------------------------------------------
1 | /*
2 | *
3 | * OceanBase Client for Java
4 | *
5 | * Copyright (c) 2021 OceanBase.
6 | *
7 | * This library is free software; you can redistribute it and/or modify it under
8 | * the terms of the GNU Lesser General Public License as published by the Free
9 | * Software Foundation; either version 2.1 of the License, or (at your option)
10 | * any later version.
11 | *
12 | * This library is distributed in the hope that it will be useful, but
13 | * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
14 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
15 | * for more details.
16 | *
17 | * Copyright (c) 2009-2011, Marcus Eriksson
18 | *
19 | * Redistribution and use in source and binary forms, with or without modification,
20 | * are permitted provided that the following conditions are met:
21 | * Redistributions of source code must retain the above copyright notice, this list
22 | * of conditions and the following disclaimer.
23 | *
24 | * Redistributions in binary form must reproduce the above copyright notice, this
25 | * list of conditions and the following disclaimer in the documentation and/or
26 | * other materials provided with the distribution.
27 | *
28 | * Neither the name of the driver nor the names of its contributors may not be
29 | * used to endorse or promote products derived from this software without specific
30 | * prior written permission.
31 | *
32 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
33 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
34 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
35 | * IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
36 | * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
37 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
38 | * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
39 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
40 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
41 | * OF SUCH DAMAGE.
42 | *
43 | */
44 | package com.oceanbase.jdbc;
45 |
46 | import java.sql.Struct;
47 |
48 | public interface ObStruct extends ObComplexData, Struct {
49 | // Ensure the interface is consistent Even if it is an empty interface
50 | }
51 |
--------------------------------------------------------------------------------
/src/main/java/com/oceanbase/jdbc/OceanBaseDatabaseMetaData.java:
--------------------------------------------------------------------------------
1 | /**
2 | * OceanBase Client for Java
3 | *
4 | * Copyright (c) 2012-2014 Monty Program Ab.
5 | * Copyright (c) 2015-2020 MariaDB Corporation Ab.
6 | * Copyright (c) 2021 OceanBase.
7 | *
8 | * This library is free software; you can redistribute it and/or modify it under
9 | * the terms of the GNU Lesser General Public License as published by the Free
10 | * Software Foundation; either version 2.1 of the License, or (at your option)
11 | * any later version.
12 | *
13 | * This library is distributed in the hope that it will be useful, but
14 | * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
15 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
16 | * for more details.
17 | *
18 | * You should have received a copy of the GNU Lesser General Public License along
19 | * with this library; if not, write to Monty Program Ab info@montyprogram.com.
20 | *
21 | * This particular MariaDB Client for Java file is work
22 | * derived from a Drizzle-JDBC. Drizzle-JDBC file which is covered by subject to
23 | * the following copyright and notice provisions:
24 | *
25 | * Copyright (c) 2009-2011, Marcus Eriksson
26 | *
27 | * Redistribution and use in source and binary forms, with or without modification,
28 | * are permitted provided that the following conditions are met:
29 | * Redistributions of source code must retain the above copyright notice, this list
30 | * of conditions and the following disclaimer.
31 | *
32 | * Redistributions in binary form must reproduce the above copyright notice, this
33 | * list of conditions and the following disclaimer in the documentation and/or
34 | * other materials provided with the distribution.
35 | *
36 | * Neither the name of the driver nor the names of its contributors may not be
37 | * used to endorse or promote products derived from this software without specific
38 | * prior written permission.
39 | *
40 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
41 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
42 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
43 | * IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
44 | * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
45 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
46 | * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
47 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
48 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
49 | * OF SUCH DAMAGE.
50 | */
51 | package com.oceanbase.jdbc;
52 |
53 | import java.sql.Connection;
54 |
55 | public class OceanBaseDatabaseMetaData extends JDBC4DatabaseMetaData {
56 | /**
57 | * Constructor.
58 | *
59 | * @param connection connection
60 | * @param urlParser Url parser
61 | */
62 | public OceanBaseDatabaseMetaData(Connection connection, UrlParser urlParser) {
63 | super(connection, urlParser);
64 | }
65 | }
--------------------------------------------------------------------------------
/src/main/java/com/oceanbase/jdbc/OceanBaseXaConnection.java:
--------------------------------------------------------------------------------
1 | /**
2 | * OceanBase Client for Java
3 | *
4 | * Copyright (c) 2012-2014 Monty Program Ab.
5 | * Copyright (c) 2015-2020 MariaDB Corporation Ab.
6 | * Copyright (c) 2021 OceanBase.
7 | *
8 | * This library is free software; you can redistribute it and/or modify it under
9 | * the terms of the GNU Lesser General Public License as published by the Free
10 | * Software Foundation; either version 2.1 of the License, or (at your option)
11 | * any later version.
12 | *
13 | * This library is distributed in the hope that it will be useful, but
14 | * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
15 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
16 | * for more details.
17 | *
18 | * You should have received a copy of the GNU Lesser General Public License along
19 | * with this library; if not, write to Monty Program Ab info@montyprogram.com.
20 | *
21 | * This particular MariaDB Client for Java file is work
22 | * derived from a Drizzle-JDBC. Drizzle-JDBC file which is covered by subject to
23 | * the following copyright and notice provisions:
24 | *
25 | * Copyright (c) 2009-2011, Marcus Eriksson
26 | *
27 | * Redistribution and use in source and binary forms, with or without modification,
28 | * are permitted provided that the following conditions are met:
29 | * Redistributions of source code must retain the above copyright notice, this list
30 | * of conditions and the following disclaimer.
31 | *
32 | * Redistributions in binary form must reproduce the above copyright notice, this
33 | * list of conditions and the following disclaimer in the documentation and/or
34 | * other materials provided with the distribution.
35 | *
36 | * Neither the name of the driver nor the names of its contributors may not be
37 | * used to endorse or promote products derived from this software without specific
38 | * prior written permission.
39 | *
40 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
41 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
42 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
43 | * IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
44 | * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
45 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
46 | * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
47 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
48 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
49 | * OF SUCH DAMAGE.
50 | */
51 | package com.oceanbase.jdbc;
52 |
53 | import javax.sql.XAConnection;
54 | import javax.transaction.xa.XAResource;
55 |
56 | public class OceanBaseXaConnection extends OceanBasePooledConnection implements XAConnection {
57 |
58 | public OceanBaseXaConnection(OceanBaseConnection connection) {
59 | super(connection);
60 | }
61 |
62 | @Override
63 | public XAResource getXAResource() {
64 | return new OceanBaseXaResource(getConnection());
65 | }
66 | }
67 |
--------------------------------------------------------------------------------
/src/main/java/com/oceanbase/jdbc/ResultSetImpl.java:
--------------------------------------------------------------------------------
1 | /**
2 | * OceanBase Client for Java
3 | *
4 | * Copyright (c) 2012-2014 Monty Program Ab.
5 | * Copyright (c) 2015-2020 MariaDB Corporation Ab.
6 | * Copyright (c) 2021 OceanBase.
7 | *
8 | * This library is free software; you can redistribute it and/or modify it under
9 | * the terms of the GNU Lesser General Public License as published by the Free
10 | * Software Foundation; either version 2.1 of the License, or (at your option)
11 | * any later version.
12 | *
13 | * This library is distributed in the hope that it will be useful, but
14 | * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
15 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
16 | * for more details.
17 | *
18 | * You should have received a copy of the GNU Lesser General Public License along
19 | * with this library; if not, write to Monty Program Ab info@montyprogram.com.
20 | *
21 | * This particular MariaDB Client for Java file is work
22 | * derived from a Drizzle-JDBC. Drizzle-JDBC file which is covered by subject to
23 | * the following copyright and notice provisions:
24 | *
25 | * Copyright (c) 2009-2011, Marcus Eriksson
26 | *
27 | * Redistribution and use in source and binary forms, with or without modification,
28 | * are permitted provided that the following conditions are met:
29 | * Redistributions of source code must retain the above copyright notice, this list
30 | * of conditions and the following disclaimer.
31 | *
32 | * Redistributions in binary form must reproduce the above copyright notice, this
33 | * list of conditions and the following disclaimer in the documentation and/or
34 | * other materials provided with the distribution.
35 | *
36 | * Neither the name of the driver nor the names of its contributors may not be
37 | * used to endorse or promote products derived from this software without specific
38 | * prior written permission.
39 | *
40 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
41 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
42 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
43 | * IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
44 | * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
45 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
46 | * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
47 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
48 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
49 | * OF SUCH DAMAGE.
50 | */
51 | package com.oceanbase.jdbc;
52 |
53 | public interface ResultSetImpl extends ObResultSet {
54 | }
55 |
--------------------------------------------------------------------------------
/src/main/java/com/oceanbase/jdbc/TnsDaemon.java:
--------------------------------------------------------------------------------
1 | package com.oceanbase.jdbc;
2 |
3 | import java.io.*;
4 | import java.nio.file.*;
5 |
6 | import com.oceanbase.jdbc.internal.failover.utils.ConfigParser;
7 |
8 | public class TnsDaemon extends Thread {
9 | private static String configFileName = "tnsnames.ob";
10 |
11 | private void fullFillMap(String tnsPath) throws IOException {
12 |
13 | String filePath = tnsPath + "/" + configFileName;
14 | File file = new File(filePath);
15 | Reader reader = new InputStreamReader(new FileInputStream(file));
16 | ConfigParser.readLoadBalanceInfosFromTns(reader);
17 | }
18 |
19 | @Override
20 | public void run() {
21 | try {
22 | ConfigParser.ConfigInfo tnsFileInfo = ConfigParser.getTnsFilePath();
23 | configFileName = tnsFileInfo.name;
24 | fullFillMap(tnsFileInfo.path);
25 | WatchService watchService = FileSystems.getDefault().newWatchService();
26 | File file1 = new File(tnsFileInfo.path);
27 | file1.toPath().register(watchService, StandardWatchEventKinds.ENTRY_MODIFY);
28 | while (true) {
29 | WatchKey key = watchService.take();
30 | for (WatchEvent> event : key.pollEvents()) {
31 | WatchEvent ev = (WatchEvent) event;
32 | Path filename = ev.context();
33 | if (filename.toString().equals(configFileName)) {
34 | fullFillMap(tnsFileInfo.path);
35 | }
36 | }
37 | boolean vaild = key.reset();
38 | if (!vaild) {
39 | break;
40 | }
41 | }
42 | } catch (Throwable throwable) {
43 | throwable.printStackTrace();
44 | }
45 | }
46 |
47 | }
48 |
--------------------------------------------------------------------------------
/src/main/java/com/oceanbase/jdbc/credential/CredentialPlugin.java:
--------------------------------------------------------------------------------
1 | /*
2 | *
3 | * OceanBase Client for Java
4 | *
5 | * Copyright (c) 2021 OceanBase.
6 | *
7 | * This library is free software; you can redistribute it and/or modify it under
8 | * the terms of the GNU Lesser General Public License as published by the Free
9 | * Software Foundation; either version 2.1 of the License, or (at your option)
10 | * any later version.
11 | *
12 | * This library is distributed in the hope that it will be useful, but
13 | * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
14 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
15 | * for more details.
16 | *
17 | * Copyright (c) 2009-2011, Marcus Eriksson
18 | *
19 | * Redistribution and use in source and binary forms, with or without modification,
20 | * are permitted provided that the following conditions are met:
21 | * Redistributions of source code must retain the above copyright notice, this list
22 | * of conditions and the following disclaimer.
23 | *
24 | * Redistributions in binary form must reproduce the above copyright notice, this
25 | * list of conditions and the following disclaimer in the documentation and/or
26 | * other materials provided with the distribution.
27 | *
28 | * Neither the name of the driver nor the names of its contributors may not be
29 | * used to endorse or promote products derived from this software without specific
30 | * prior written permission.
31 | *
32 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
33 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
34 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
35 | * IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
36 | * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
37 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
38 | * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
39 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
40 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
41 | * OF SUCH DAMAGE.
42 | *
43 | */
44 | package com.oceanbase.jdbc.credential;
45 |
46 | import java.sql.SQLException;
47 | import java.util.function.Supplier;
48 |
49 | import com.oceanbase.jdbc.HostAddress;
50 | import com.oceanbase.jdbc.util.Options;
51 |
52 | public interface CredentialPlugin extends Supplier {
53 |
54 | String name();
55 |
56 | String type();
57 |
58 | default boolean mustUseSsl() {
59 | return false;
60 | }
61 |
62 | default String defaultAuthenticationPluginType() {
63 | return null;
64 | }
65 |
66 | default CredentialPlugin initialize(Options options, String userName, HostAddress hostAddress)
67 | throws SQLException {
68 | return this;
69 | }
70 | }
71 |
--------------------------------------------------------------------------------
/src/main/java/com/oceanbase/jdbc/extend/datatype/RAW.java:
--------------------------------------------------------------------------------
1 | /*
2 | *
3 | * OceanBase Client for Java
4 | *
5 | * Copyright (c) 2021 OceanBase.
6 | *
7 | * This library is free software; you can redistribute it and/or modify it under
8 | * the terms of the GNU Lesser General Public License as published by the Free
9 | * Software Foundation; either version 2.1 of the License, or (at your option)
10 | * any later version.
11 | *
12 | * This library is distributed in the hope that it will be useful, but
13 | * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
14 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
15 | * for more details.
16 | *
17 | * Copyright (c) 2009-2011, Marcus Eriksson
18 | *
19 | * Redistribution and use in source and binary forms, with or without modification,
20 | * are permitted provided that the following conditions are met:
21 | * Redistributions of source code must retain the above copyright notice, this list
22 | * of conditions and the following disclaimer.
23 | *
24 | * Redistributions in binary form must reproduce the above copyright notice, this
25 | * list of conditions and the following disclaimer in the documentation and/or
26 | * other materials provided with the distribution.
27 | *
28 | * Neither the name of the driver nor the names of its contributors may not be
29 | * used to endorse or promote products derived from this software without specific
30 | * prior written permission.
31 | *
32 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
33 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
34 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
35 | * IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
36 | * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
37 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
38 | * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
39 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
40 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
41 | * OF SUCH DAMAGE.
42 | *
43 | */
44 | package com.oceanbase.jdbc.extend.datatype;
45 |
46 | import java.sql.SQLException;
47 |
48 | public class RAW extends Datum {
49 | public RAW(byte[] bytes) {
50 | super(bytes);
51 | }
52 |
53 | public RAW(Object val) {
54 | }
55 |
56 | @Override
57 | public boolean isConvertibleTo(Class targetClass) {
58 | return false;
59 | }
60 |
61 | @Override
62 | public Object toJdbc() throws SQLException {
63 | return null;
64 | }
65 |
66 | @Override
67 | public Object makeJdbcArray(int intVal) {
68 | return null;
69 | }
70 | }
71 |
--------------------------------------------------------------------------------
/src/main/java/com/oceanbase/jdbc/extend/datatype/RowIdImpl.java:
--------------------------------------------------------------------------------
1 | /*
2 | *
3 | * OceanBase Client for Java
4 | *
5 | * Copyright (c) 2021 OceanBase.
6 | *
7 | * This library is free software; you can redistribute it and/or modify it under
8 | * the terms of the GNU Lesser General Public License as published by the Free
9 | * Software Foundation; either version 2.1 of the License, or (at your option)
10 | * any later version.
11 | *
12 | * This library is distributed in the hope that it will be useful, but
13 | * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
14 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
15 | * for more details.
16 | *
17 | * Copyright (c) 2009-2011, Marcus Eriksson
18 | *
19 | * Redistribution and use in source and binary forms, with or without modification,
20 | * are permitted provided that the following conditions are met:
21 | * Redistributions of source code must retain the above copyright notice, this list
22 | * of conditions and the following disclaimer.
23 | *
24 | * Redistributions in binary form must reproduce the above copyright notice, this
25 | * list of conditions and the following disclaimer in the documentation and/or
26 | * other materials provided with the distribution.
27 | *
28 | * Neither the name of the driver nor the names of its contributors may not be
29 | * used to endorse or promote products derived from this software without specific
30 | * prior written permission.
31 | *
32 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
33 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
34 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
35 | * IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
36 | * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
37 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
38 | * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
39 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
40 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
41 | * OF SUCH DAMAGE.
42 | *
43 | */
44 | package com.oceanbase.jdbc.extend.datatype;
45 |
46 | public class RowIdImpl implements java.sql.RowId {
47 | private String val;
48 |
49 | public RowIdImpl(String value) {
50 | val = value;
51 | }
52 |
53 | @Override
54 | public boolean equals(Object obj) {
55 | if (obj instanceof RowIdImpl) {
56 | if (obj.hashCode() == this.hashCode()) {
57 | return true;
58 | }
59 | }
60 | return false;
61 | }
62 |
63 | @Override
64 | public byte[] getBytes() {
65 | if (val != null) {
66 | return val.getBytes();
67 | } else {
68 | return new byte[0];
69 | }
70 | }
71 |
72 | @Override
73 | public String toString() {
74 | return val;
75 | }
76 |
77 | @Override
78 | public int hashCode() {
79 | return val != null ? val.hashCode() : 0;
80 |
81 | }
82 | }
83 |
--------------------------------------------------------------------------------
/src/main/java/com/oceanbase/jdbc/extend/datatype/StructImpl.java:
--------------------------------------------------------------------------------
1 | /*
2 | *
3 | * OceanBase Client for Java
4 | *
5 | * Copyright (c) 2021 OceanBase.
6 | *
7 | * This library is free software; you can redistribute it and/or modify it under
8 | * the terms of the GNU Lesser General Public License as published by the Free
9 | * Software Foundation; either version 2.1 of the License, or (at your option)
10 | * any later version.
11 | *
12 | * This library is distributed in the hope that it will be useful, but
13 | * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
14 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
15 | * for more details.
16 | *
17 | * Copyright (c) 2009-2011, Marcus Eriksson
18 | *
19 | * Redistribution and use in source and binary forms, with or without modification,
20 | * are permitted provided that the following conditions are met:
21 | * Redistributions of source code must retain the above copyright notice, this list
22 | * of conditions and the following disclaimer.
23 | *
24 | * Redistributions in binary form must reproduce the above copyright notice, this
25 | * list of conditions and the following disclaimer in the documentation and/or
26 | * other materials provided with the distribution.
27 | *
28 | * Neither the name of the driver nor the names of its contributors may not be
29 | * used to endorse or promote products derived from this software without specific
30 | * prior written permission.
31 | *
32 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
33 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
34 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
35 | * IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
36 | * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
37 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
38 | * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
39 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
40 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
41 | * OF SUCH DAMAGE.
42 | *
43 | */
44 | package com.oceanbase.jdbc.extend.datatype;
45 |
46 | import java.sql.SQLException;
47 | import java.util.Map;
48 |
49 | import com.oceanbase.jdbc.ObStruct;
50 |
51 | public class StructImpl extends ComplexData implements ObStruct {
52 | public StructImpl(ComplexDataType type) {
53 | super(type);
54 | }
55 |
56 | @Override
57 | public String getSQLTypeName() throws SQLException {
58 | return this.getComplexType().getTypeName();
59 | }
60 |
61 | @Override
62 | public Object[] getAttributes() throws SQLException {
63 | return this.getAttrData();
64 | }
65 |
66 | @Override
67 | public Object[] getAttributes(Map> map) throws SQLException {
68 | return new Object[0];
69 | }
70 | }
71 |
--------------------------------------------------------------------------------
/src/main/java/com/oceanbase/jdbc/internal/ObOracleDefs.java:
--------------------------------------------------------------------------------
1 | /*
2 | *
3 | * OceanBase Client for Java
4 | *
5 | * Copyright (c) 2021 OceanBase.
6 | *
7 | * This library is free software; you can redistribute it and/or modify it under
8 | * the terms of the GNU Lesser General Public License as published by the Free
9 | * Software Foundation; either version 2.1 of the License, or (at your option)
10 | * any later version.
11 | *
12 | * This library is distributed in the hope that it will be useful, but
13 | * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
14 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
15 | * for more details.
16 | *
17 | * Copyright (c) 2009-2011, Marcus Eriksson
18 | *
19 | * Redistribution and use in source and binary forms, with or without modification,
20 | * are permitted provided that the following conditions are met:
21 | * Redistributions of source code must retain the above copyright notice, this list
22 | * of conditions and the following disclaimer.
23 | *
24 | * Redistributions in binary form must reproduce the above copyright notice, this
25 | * list of conditions and the following disclaimer in the documentation and/or
26 | * other materials provided with the distribution.
27 | *
28 | * Neither the name of the driver nor the names of its contributors may not be
29 | * used to endorse or promote products derived from this software without specific
30 | * prior written permission.
31 | *
32 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
33 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
34 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
35 | * IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
36 | * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
37 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
38 | * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
39 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
40 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
41 | * OF SUCH DAMAGE.
42 | *
43 | */
44 | package com.oceanbase.jdbc.internal;
45 |
46 | /***
47 | * Describes the Oracle field type
48 | */
49 | public class ObOracleDefs {
50 |
51 | public static final int FIELD_JAVA_TYPE_BINARY_DOUBLE = 101;
52 |
53 | public static final int FIELD_JAVA_TYPE_BINARY_FLOAT = 100;
54 |
55 | public static final int FIELD_JAVA_TYPE_NVARCHAR2 = -9;
56 |
57 | public static final int FIELD_JAVA_TYPE_NUMBER = 2;
58 |
59 | public static final int FIELD_JAVA_TYPE_ROWID = -8;
60 |
61 | public static final int FIELD_JAVA_TYPE_NCHAR = -15;
62 |
63 | public static final int FIELD_JAVA_TYPE_CLOB = 2005;
64 |
65 | public static final int FIELD_JAVA_TYPE_INTERVALYM = -103;
66 | public static final int FIELD_JAVA_TYPE_INTERVALDS = -104;
67 |
68 | }
69 |
--------------------------------------------------------------------------------
/src/main/java/com/oceanbase/jdbc/internal/com/read/resultset/Cursor.java:
--------------------------------------------------------------------------------
1 | package com.oceanbase.jdbc.internal.com.read.resultset;
2 |
3 | import java.io.IOException;
4 | import java.sql.SQLException;
5 |
6 | import com.oceanbase.jdbc.internal.com.read.dao.Results;
7 | import com.oceanbase.jdbc.internal.protocol.Protocol;
8 |
9 | public abstract class Cursor extends SelectResultSet {
10 | public Cursor(ColumnDefinition[] columnDefinition, Results results, Protocol protocol,
11 | boolean callableResult, boolean eofDeprecated, boolean isPsOutParameter)
12 | throws IOException,
13 | SQLException {
14 | super(columnDefinition, results, protocol, callableResult, eofDeprecated, isPsOutParameter);
15 | }
16 |
17 | protected abstract boolean cursorFetch() throws SQLException;
18 |
19 | }
20 |
--------------------------------------------------------------------------------
/src/main/java/com/oceanbase/jdbc/internal/com/read/resultset/rowprotocol/OperationNotSupportedException.java:
--------------------------------------------------------------------------------
1 | /**
2 | * OceanBase Client for Java
3 | *
4 | * Copyright (c) 2012-2014 Monty Program Ab.
5 | * Copyright (c) 2015-2020 MariaDB Corporation Ab.
6 | * Copyright (c) 2021 OceanBase.
7 | *
8 | * This library is free software; you can redistribute it and/or modify it under
9 | * the terms of the GNU Lesser General Public License as published by the Free
10 | * Software Foundation; either version 2.1 of the License, or (at your option)
11 | * any later version.
12 | *
13 | * This library is distributed in the hope that it will be useful, but
14 | * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
15 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
16 | * for more details.
17 | *
18 | * You should have received a copy of the GNU Lesser General Public License along
19 | * with this library; if not, write to Monty Program Ab info@montyprogram.com.
20 | *
21 | * This particular MariaDB Client for Java file is work
22 | * derived from a Drizzle-JDBC. Drizzle-JDBC file which is covered by subject to
23 | * the following copyright and notice provisions:
24 | *
25 | * Copyright (c) 2009-2011, Marcus Eriksson
26 | *
27 | * Redistribution and use in source and binary forms, with or without modification,
28 | * are permitted provided that the following conditions are met:
29 | * Redistributions of source code must retain the above copyright notice, this list
30 | * of conditions and the following disclaimer.
31 | *
32 | * Redistributions in binary form must reproduce the above copyright notice, this
33 | * list of conditions and the following disclaimer in the documentation and/or
34 | * other materials provided with the distribution.
35 | *
36 | * Neither the name of the driver nor the names of its contributors may not be
37 | * used to endorse or promote products derived from this software without specific
38 | * prior written permission.
39 | *
40 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
41 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
42 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
43 | * IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
44 | * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
45 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
46 | * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
47 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
48 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
49 | * OF SUCH DAMAGE.
50 | */
51 | package com.oceanbase.jdbc.internal.com.read.resultset.rowprotocol;
52 |
53 | import java.sql.SQLException;
54 |
55 | class OperationNotSupportedException extends SQLException {
56 |
57 | static final long serialVersionUID = 474918612056813430L;
58 |
59 | OperationNotSupportedException() {
60 | }
61 | }
--------------------------------------------------------------------------------
/src/main/java/com/oceanbase/jdbc/internal/com/send/ComStmtFetch.java:
--------------------------------------------------------------------------------
1 | /**
2 | * OceanBase Client for Java
3 | *
4 | * Copyright (c) 2012-2014 Monty Program Ab.
5 | * Copyright (c) 2015-2020 MariaDB Corporation Ab.
6 | * Copyright (c) 2021 OceanBase.
7 | *
8 | * This library is free software; you can redistribute it and/or modify it under
9 | * the terms of the GNU Lesser General Public License as published by the Free
10 | * Software Foundation; either version 2.1 of the License, or (at your option)
11 | * any later version.
12 | *
13 | * This library is distributed in the hope that it will be useful, but
14 | * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
15 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
16 | * for more details.
17 | *
18 | * You should have received a copy of the GNU Lesser General Public License along
19 | * with this library; if not, write to Monty Program Ab info@montyprogram.com.
20 | *
21 | * This particular MariaDB Client for Java file is work
22 | * derived from a Drizzle-JDBC. Drizzle-JDBC file which is covered by subject to
23 | * the following copyright and notice provisions:
24 | *
25 | * Copyright (c) 2009-2011, Marcus Eriksson
26 | *
27 | * Redistribution and use in source and binary forms, with or without modification,
28 | * are permitted provided that the following conditions are met:
29 | * Redistributions of source code must retain the above copyright notice, this list
30 | * of conditions and the following disclaimer.
31 | *
32 | * Redistributions in binary form must reproduce the above copyright notice, this
33 | * list of conditions and the following disclaimer in the documentation and/or
34 | * other materials provided with the distribution.
35 | *
36 | * Neither the name of the driver nor the names of its contributors may not be
37 | * used to endorse or promote products derived from this software without specific
38 | * prior written permission.
39 | *
40 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
41 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
42 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
43 | * IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
44 | * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
45 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
46 | * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
47 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
48 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
49 | * OF SUCH DAMAGE.
50 | */
51 | package com.oceanbase.jdbc.internal.com.send;
52 |
53 | import java.io.IOException;
54 |
55 | import com.oceanbase.jdbc.internal.com.Packet;
56 | import com.oceanbase.jdbc.internal.io.output.PacketOutputStream;
57 |
58 | public class ComStmtFetch {
59 | /**
60 | *
61 | * @param pos
62 | * @param fetchSize
63 | * @throws IOException
64 | */
65 | public static void send(final PacketOutputStream pos, int fetchSize, int statementId)
66 | throws IOException {
67 | pos.startPacket(0);
68 | pos.write(Packet.COM_STMT_FETCH);
69 | pos.writeInt(statementId);
70 | pos.writeInt(fetchSize);
71 | pos.flush();
72 | }
73 | }
74 |
--------------------------------------------------------------------------------
/src/main/java/com/oceanbase/jdbc/internal/com/send/SendClosePacket.java:
--------------------------------------------------------------------------------
1 | /**
2 | * OceanBase Client for Java
3 | *
4 | * Copyright (c) 2012-2014 Monty Program Ab.
5 | * Copyright (c) 2015-2020 MariaDB Corporation Ab.
6 | * Copyright (c) 2021 OceanBase.
7 | *
8 | * This library is free software; you can redistribute it and/or modify it under
9 | * the terms of the GNU Lesser General Public License as published by the Free
10 | * Software Foundation; either version 2.1 of the License, or (at your option)
11 | * any later version.
12 | *
13 | * This library is distributed in the hope that it will be useful, but
14 | * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
15 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
16 | * for more details.
17 | *
18 | * You should have received a copy of the GNU Lesser General Public License along
19 | * with this library; if not, write to Monty Program Ab info@montyprogram.com.
20 | *
21 | * This particular MariaDB Client for Java file is work
22 | * derived from a Drizzle-JDBC. Drizzle-JDBC file which is covered by subject to
23 | * the following copyright and notice provisions:
24 | *
25 | * Copyright (c) 2009-2011, Marcus Eriksson
26 | *
27 | * Redistribution and use in source and binary forms, with or without modification,
28 | * are permitted provided that the following conditions are met:
29 | * Redistributions of source code must retain the above copyright notice, this list
30 | * of conditions and the following disclaimer.
31 | *
32 | * Redistributions in binary form must reproduce the above copyright notice, this
33 | * list of conditions and the following disclaimer in the documentation and/or
34 | * other materials provided with the distribution.
35 | *
36 | * Neither the name of the driver nor the names of its contributors may not be
37 | * used to endorse or promote products derived from this software without specific
38 | * prior written permission.
39 | *
40 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
41 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
42 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
43 | * IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
44 | * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
45 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
46 | * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
47 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
48 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
49 | * OF SUCH DAMAGE.
50 | */
51 | package com.oceanbase.jdbc.internal.com.send;
52 |
53 | import java.io.IOException;
54 |
55 | import com.oceanbase.jdbc.internal.com.Packet;
56 | import com.oceanbase.jdbc.internal.io.output.PacketOutputStream;
57 |
58 | public class SendClosePacket {
59 |
60 | /**
61 | * Send close stream to server.
62 | *
63 | * @param pos write outputStream
64 | */
65 | public static void send(final PacketOutputStream pos) {
66 | try {
67 | pos.startPacket(0);
68 | pos.write(Packet.COM_QUIT);
69 | pos.flush();
70 | } catch (IOException ioe) {
71 | // eat
72 | }
73 | }
74 | }
75 |
--------------------------------------------------------------------------------
/src/main/java/com/oceanbase/jdbc/internal/com/send/authentication/ed25519/README:
--------------------------------------------------------------------------------
1 | This plugin uses public domain ed25519 code by str4d (https://github.com/str4d/ed25519-java).
2 | It is "ref10" java implementation from the SUPERCOP ed25519:
3 |
4 | ==============================
5 | MariaDB changes:
6 | - doesn't register ed25519 to global java providers
7 | - remove unused classes
8 |
--------------------------------------------------------------------------------
/src/main/java/com/oceanbase/jdbc/internal/com/send/authentication/gssapi/GssapiAuth.java:
--------------------------------------------------------------------------------
1 | /**
2 | * OceanBase Client for Java
3 | *
4 | * Copyright (c) 2012-2014 Monty Program Ab.
5 | * Copyright (c) 2015-2020 MariaDB Corporation Ab.
6 | * Copyright (c) 2021 OceanBase.
7 | *
8 | * This library is free software; you can redistribute it and/or modify it under
9 | * the terms of the GNU Lesser General Public License as published by the Free
10 | * Software Foundation; either version 2.1 of the License, or (at your option)
11 | * any later version.
12 | *
13 | * This library is distributed in the hope that it will be useful, but
14 | * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
15 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
16 | * for more details.
17 | *
18 | * You should have received a copy of the GNU Lesser General Public License along
19 | * with this library; if not, write to Monty Program Ab info@montyprogram.com.
20 | *
21 | * This particular MariaDB Client for Java file is work
22 | * derived from a Drizzle-JDBC. Drizzle-JDBC file which is covered by subject to
23 | * the following copyright and notice provisions:
24 | *
25 | * Copyright (c) 2009-2011, Marcus Eriksson
26 | *
27 | * Redistribution and use in source and binary forms, with or without modification,
28 | * are permitted provided that the following conditions are met:
29 | * Redistributions of source code must retain the above copyright notice, this list
30 | * of conditions and the following disclaimer.
31 | *
32 | * Redistributions in binary form must reproduce the above copyright notice, this
33 | * list of conditions and the following disclaimer in the documentation and/or
34 | * other materials provided with the distribution.
35 | *
36 | * Neither the name of the driver nor the names of its contributors may not be
37 | * used to endorse or promote products derived from this software without specific
38 | * prior written permission.
39 | *
40 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
41 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
42 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
43 | * IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
44 | * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
45 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
46 | * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
47 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
48 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
49 | * OF SUCH DAMAGE.
50 | */
51 | package com.oceanbase.jdbc.internal.com.send.authentication.gssapi;
52 |
53 | import java.io.IOException;
54 | import java.sql.SQLException;
55 | import java.util.concurrent.atomic.AtomicInteger;
56 |
57 | import com.oceanbase.jdbc.internal.io.input.PacketInputStream;
58 | import com.oceanbase.jdbc.internal.io.output.PacketOutputStream;
59 |
60 | public interface GssapiAuth {
61 |
62 | void authenticate(PacketOutputStream writer, PacketInputStream in, AtomicInteger sequence,
63 | String servicePrincipalName, String mechanisms) throws SQLException,
64 | IOException;
65 | }
66 |
--------------------------------------------------------------------------------
/src/main/java/com/oceanbase/jdbc/internal/com/send/parameters/LongDataParameterHolder.java:
--------------------------------------------------------------------------------
1 | /*
2 | *
3 | * OceanBase Client for Java
4 | *
5 | * Copyright (c) 2021 OceanBase.
6 | *
7 | * This library is free software; you can redistribute it and/or modify it under
8 | * the terms of the GNU Lesser General Public License as published by the Free
9 | * Software Foundation; either version 2.1 of the License, or (at your option)
10 | * any later version.
11 | *
12 | * This library is distributed in the hope that it will be useful, but
13 | * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
14 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
15 | * for more details.
16 | *
17 | * Copyright (c) 2009-2011, Marcus Eriksson
18 | *
19 | * Redistribution and use in source and binary forms, with or without modification,
20 | * are permitted provided that the following conditions are met:
21 | * Redistributions of source code must retain the above copyright notice, this list
22 | * of conditions and the following disclaimer.
23 | *
24 | * Redistributions in binary form must reproduce the above copyright notice, this
25 | * list of conditions and the following disclaimer in the documentation and/or
26 | * other materials provided with the distribution.
27 | *
28 | * Neither the name of the driver nor the names of its contributors may not be
29 | * used to endorse or promote products derived from this software without specific
30 | * prior written permission.
31 | *
32 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
33 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
34 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
35 | * IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
36 | * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
37 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
38 | * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
39 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
40 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
41 | * OF SUCH DAMAGE.
42 | *
43 | */
44 |
45 | package com.oceanbase.jdbc.internal.com.send.parameters;
46 |
47 | import java.io.IOException;
48 | import java.sql.SQLException;
49 |
50 | import com.oceanbase.jdbc.internal.io.output.PacketOutputStream;
51 | import com.oceanbase.jdbc.util.Options;
52 |
53 | public interface LongDataParameterHolder extends ParameterHolder {
54 | public static final int BLOB_STREAM_READ_BUF_SIZE = 8192; // Transplant this one from objdbc 1.x
55 |
56 | public boolean writePieceData(final PacketOutputStream pos, boolean first, Options options)
57 | throws IOException, SQLException;
58 |
59 | public boolean writeLongData(final PacketOutputStream pos, Options options, int statementId,
60 | short paramIndex) throws IOException, SQLException;
61 | }
62 |
--------------------------------------------------------------------------------
/src/main/java/com/oceanbase/jdbc/internal/com/send/parameters/OBEmptyLobParameter.java:
--------------------------------------------------------------------------------
1 | package com.oceanbase.jdbc.internal.com.send.parameters;
2 |
3 | import java.io.IOException;
4 |
5 | import com.oceanbase.jdbc.internal.ColumnType;
6 | import com.oceanbase.jdbc.internal.io.output.PacketOutputStream;
7 |
8 | public class OBEmptyLobParameter implements Cloneable, ParameterHolder {
9 |
10 | int lobType = 0; // 0 blob / 1 clob
11 | private byte[] lobLocatorBinary = null;
12 | private static final byte[] EMPTY_CLOB = { 'E', 'M', 'P', 'T', 'Y', '_', 'C', 'L', 'O',
13 | 'B', '(', ')' };
14 | private static final byte[] EMPTY_BLOB = { 'E', 'M', 'P', 'T', 'Y', '_', 'B', 'L', 'O',
15 | 'B', '(', ')' };
16 |
17 | public OBEmptyLobParameter(int lobType) {
18 | this.lobType = lobType;
19 | }
20 |
21 | public OBEmptyLobParameter(int lobType, byte[] lobLocatorBinary) {
22 | this.lobType = lobType;
23 | this.lobLocatorBinary = lobLocatorBinary;
24 | }
25 |
26 | @Override
27 | public void writeTo(PacketOutputStream os) throws IOException {
28 | if (this.lobType == 0) {
29 | os.write(EMPTY_BLOB);
30 | } else {
31 | os.write(EMPTY_CLOB);
32 | }
33 | }
34 |
35 | @Override
36 | public void writeBinary(PacketOutputStream pos) throws IOException {
37 | if (lobLocatorBinary != null) {
38 | pos.writeFieldLength(lobLocatorBinary.length);
39 | pos.write(lobLocatorBinary, 0, lobLocatorBinary.length);
40 | }
41 | // writing through reader is equivalent to writing nothing
42 | }
43 |
44 | @Override
45 | public int getApproximateTextProtocolLength() throws IOException {
46 | return 0;
47 | }
48 |
49 | @Override
50 | public boolean isNullData() {
51 | return lobLocatorBinary == null;
52 | }
53 |
54 | /**
55 | *
56 | * @return ColumnType.ORA_CLOB/ORA_CLOB write through locator, and ColumnType.STRING write through reader
57 | */
58 | @Override
59 | public ColumnType getColumnType() {
60 | return lobLocatorBinary != null ? (lobType == 0 ? ColumnType.ORA_BLOB : ColumnType.ORA_CLOB)
61 | : ColumnType.STRING;
62 | }
63 |
64 | @Override
65 | public boolean isLongData() {
66 | return false;
67 | }
68 | }
69 |
--------------------------------------------------------------------------------
/src/main/java/com/oceanbase/jdbc/internal/com/send/parameters/OBStringParameter.java:
--------------------------------------------------------------------------------
1 | package com.oceanbase.jdbc.internal.com.send.parameters;
2 |
3 | import com.oceanbase.jdbc.internal.ColumnType;
4 |
5 | public class OBStringParameter extends OBVarcharParameter {
6 |
7 | public OBStringParameter(String str, boolean noBackslashEscapes, String characterEncoding) {
8 | super(str, noBackslashEscapes, characterEncoding);
9 | }
10 |
11 | public ColumnType getColumnType() {
12 | return ColumnType.STRING;
13 | }
14 |
15 | }
16 |
--------------------------------------------------------------------------------
/src/main/java/com/oceanbase/jdbc/internal/failover/BlackList/BlackListConfig.java:
--------------------------------------------------------------------------------
1 | package com.oceanbase.jdbc.internal.failover.BlackList;
2 |
3 | import java.util.HashMap;
4 |
5 | import com.oceanbase.jdbc.internal.failover.BlackList.append.AppendStrategy;
6 | import com.oceanbase.jdbc.internal.failover.BlackList.append.NormalAppend;
7 | import com.oceanbase.jdbc.internal.failover.BlackList.recover.RemoveStrategy;
8 | import com.oceanbase.jdbc.internal.failover.BlackList.recover.TimeoutRecover;
9 |
10 | public class BlackListConfig {
11 | RemoveStrategy removeStrategy;
12 | AppendStrategy appendStrategy;
13 | HashMap removeStrategyConfigs;
14 | HashMap appendStrategyConfigs;
15 |
16 | public BlackListConfig() {
17 | appendStrategyConfigs = new HashMap<>();
18 | appendStrategyConfigs.put("NAME","NORMAL");
19 | removeStrategyConfigs = new HashMap<>();
20 | removeStrategyConfigs.put("NAME","TIMEOUT");
21 | removeStrategyConfigs.put("TIMEOUT","50");
22 | }
23 |
24 | public BlackListConfig(boolean byDefault) {
25 | if (byDefault) {
26 | appendStrategy = new NormalAppend();
27 | removeStrategy = new TimeoutRecover();
28 | }
29 | }
30 |
31 | @Override
32 | public String toString() {
33 | return "BlackListConfig{" + "removeStrategy=" + removeStrategy + ", appendStrategy="
34 | + appendStrategy + '}';
35 | }
36 |
37 | public String toJson() {
38 | StringBuilder json = new StringBuilder("\"OBLB_BLACKLIST\":{\n");
39 | boolean atLeastOne = false;
40 |
41 | if (removeStrategy != null) {
42 | atLeastOne = true;
43 | json.append(removeStrategy.toJson());
44 | }
45 | if (appendStrategy != null) {
46 | if (atLeastOne) {
47 | json.append(",");
48 | }
49 | json.append(appendStrategy.toJson());
50 | }
51 |
52 | json.append("}");
53 | return json.toString();
54 | }
55 |
56 | public HashMap getRemoveStrategyConfigs() {
57 | return removeStrategyConfigs;
58 | }
59 |
60 | public void setRemoveStrategyConfigs(HashMap removeStrategyConfigs) {
61 | this.removeStrategyConfigs = removeStrategyConfigs;
62 | }
63 |
64 | public HashMap getAppendStrategyConfigs() {
65 | return appendStrategyConfigs;
66 | }
67 |
68 | public void setAppendStrategyConfigs(HashMap appendStrategyConfigs) {
69 | this.appendStrategyConfigs = appendStrategyConfigs;
70 | }
71 |
72 | public RemoveStrategy getRemoveStrategy() {
73 | return removeStrategy;
74 | }
75 |
76 | public void setRemoveStrategy(RemoveStrategy removeStrategy) {
77 | this.removeStrategy = removeStrategy;
78 | }
79 |
80 | public AppendStrategy getAppendStrategy() {
81 | return appendStrategy;
82 | }
83 |
84 | public void setAppendStrategy(AppendStrategy appendStrategy) {
85 | this.appendStrategy = appendStrategy;
86 | }
87 |
88 | }
89 |
--------------------------------------------------------------------------------
/src/main/java/com/oceanbase/jdbc/internal/failover/BlackList/append/AppendStrategy.java:
--------------------------------------------------------------------------------
1 | package com.oceanbase.jdbc.internal.failover.BlackList.append;
2 |
3 | import java.util.Properties;
4 |
5 | import com.oceanbase.jdbc.HostAddress;
6 |
7 | public interface AppendStrategy {
8 |
9 | String toJson();
10 |
11 | boolean needToAppend(HostAddress hostAddress, Properties properties);
12 | }
13 |
--------------------------------------------------------------------------------
/src/main/java/com/oceanbase/jdbc/internal/failover/BlackList/append/NormalAppend.java:
--------------------------------------------------------------------------------
1 | package com.oceanbase.jdbc.internal.failover.BlackList.append;
2 |
3 | import java.util.Properties;
4 |
5 | import com.oceanbase.jdbc.HostAddress;
6 | import com.oceanbase.jdbc.internal.failover.BlackList.append.AppendStrategy;
7 |
8 | public class NormalAppend implements AppendStrategy {
9 |
10 | @Override
11 | public String toString() {
12 | return "NormalAppend{}";
13 | }
14 |
15 | public String toJson() {
16 | return "\"APPEND_STRATEGY\":{\"NAME\":\"NORMAL\"}";
17 | }
18 |
19 | @Override
20 | public boolean needToAppend(HostAddress hostAddress, Properties properties) {
21 | return true;
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/src/main/java/com/oceanbase/jdbc/internal/failover/BlackList/recover/RemoveStrategy.java:
--------------------------------------------------------------------------------
1 | package com.oceanbase.jdbc.internal.failover.BlackList.recover;
2 |
3 | import com.oceanbase.jdbc.internal.failover.utils.HostStateInfo;
4 |
5 | public interface RemoveStrategy {
6 |
7 | String toJson();
8 |
9 | boolean needToChangeStateInfo(HostStateInfo hostStateInfo);
10 | }
11 |
--------------------------------------------------------------------------------
/src/main/java/com/oceanbase/jdbc/internal/failover/BlackList/recover/TimeoutRecover.java:
--------------------------------------------------------------------------------
1 | package com.oceanbase.jdbc.internal.failover.BlackList.recover;
2 |
3 | import java.util.concurrent.TimeUnit;
4 |
5 | import com.oceanbase.jdbc.internal.failover.BlackList.recover.RemoveStrategy;
6 | import com.oceanbase.jdbc.internal.failover.utils.HostStateInfo;
7 |
8 | public class TimeoutRecover implements RemoveStrategy {
9 | long timeout;
10 |
11 | public TimeoutRecover() {
12 | this.timeout = 50;
13 | }
14 |
15 | public TimeoutRecover(long timeout) {
16 | this.timeout = timeout;
17 | }
18 |
19 | @Override
20 | public String toString() {
21 | return "TimeoutRecover{}";
22 | }
23 |
24 | public String toJson() {
25 | return "\"REMOVE_STRATEGY\":{" + "\"NAME\":\"TIMEOUT\"," + "\"TIMEOUT\":" + timeout + "}";
26 | }
27 |
28 | public long getTimeout() {
29 | return timeout;
30 | }
31 |
32 | public void setTimeout(long timeout) {
33 | this.timeout = timeout;
34 | }
35 |
36 | @Override
37 | public boolean needToChangeStateInfo(HostStateInfo hostStateInfo) {
38 | long currentTimeNanos = System.nanoTime();
39 | long entryNanos = hostStateInfo.getTimestamp();
40 | long durationSeconds = TimeUnit.NANOSECONDS.toSeconds(currentTimeNanos - entryNanos);
41 | if (durationSeconds >= timeout) {
42 | return true;
43 | } else {
44 | return false;
45 | }
46 | }
47 | }
48 |
--------------------------------------------------------------------------------
/src/main/java/com/oceanbase/jdbc/internal/failover/LoadBalanceStrategy/BalanceStrategy.java:
--------------------------------------------------------------------------------
1 | package com.oceanbase.jdbc.internal.failover.LoadBalanceStrategy;
2 |
3 | import java.sql.SQLException;
4 | import java.util.List;
5 | import java.util.Set;
6 | import java.util.concurrent.ConcurrentMap;
7 |
8 | import com.oceanbase.jdbc.HostAddress;
9 | import com.oceanbase.jdbc.UrlParser;
10 | import com.oceanbase.jdbc.internal.failover.Listener;
11 | import com.oceanbase.jdbc.internal.failover.impl.LoadBalanceAddressList;
12 | import com.oceanbase.jdbc.internal.failover.tools.SearchFilter;
13 | import com.oceanbase.jdbc.internal.failover.utils.HostStateInfo;
14 | import com.oceanbase.jdbc.internal.util.pool.GlobalStateInfo;
15 |
16 | public interface BalanceStrategy {
17 |
18 | String toJson();
19 |
20 | static boolean allBlack(List loopAddress, ConcurrentMap blacklist ) {
21 | if(blacklist.keySet().size() == 0) {
22 | return false;
23 | }
24 | if(!blacklist.keySet().containsAll(loopAddress)) {
25 | return false;
26 | }
27 | for(HostAddress hostAddress : blacklist.keySet()) {
28 | if (loopAddress.contains(hostAddress) && blacklist.get(hostAddress).getState() != HostStateInfo.STATE.BLACK) {
29 | return false;
30 | }
31 | }
32 | return true;
33 | }
34 |
35 | /**
36 | * Select a proper connection based on the current configuration information
37 | * @param loadBalanceAddressList current load balance config info
38 | * @param urlParser url parser,get options from it
39 | * @param listener current listener
40 | * @param globalInfo global info
41 | * @param searchFilter filter
42 | * @param blacklist current black host list
43 | * @throws SQLException
44 | */
45 | void pickConnection(LoadBalanceAddressList loadBalanceAddressList, UrlParser urlParser,
46 | Listener listener, final GlobalStateInfo globalInfo,
47 | SearchFilter searchFilter,
48 | ConcurrentMap blacklist,
49 | Set pickedList) throws SQLException;
50 |
51 | void pickConnectionFallThrough(LoadBalanceAddressList loadBalanceAddressList,
52 | Listener listener, GlobalStateInfo globalInfo)
53 | throws SQLException;
54 | }
55 |
--------------------------------------------------------------------------------
/src/main/java/com/oceanbase/jdbc/internal/failover/LoadBalanceStrategy/GroupBalanceStrategy.java:
--------------------------------------------------------------------------------
1 | package com.oceanbase.jdbc.internal.failover.LoadBalanceStrategy;
2 |
3 | import java.sql.SQLException;
4 | import java.util.List;
5 | import java.util.Set;
6 | import java.util.concurrent.ConcurrentMap;
7 |
8 | import com.oceanbase.jdbc.HostAddress;
9 | import com.oceanbase.jdbc.UrlParser;
10 | import com.oceanbase.jdbc.internal.failover.Listener;
11 | import com.oceanbase.jdbc.internal.failover.impl.LoadBalanceAddressList;
12 | import com.oceanbase.jdbc.internal.failover.tools.SearchFilter;
13 | import com.oceanbase.jdbc.internal.failover.utils.HostStateInfo;
14 | import com.oceanbase.jdbc.internal.util.pool.GlobalStateInfo;
15 |
16 | public interface GroupBalanceStrategy {
17 |
18 | String toJson();
19 |
20 | void pickAddressList(List groups, UrlParser urlParser,
21 | Listener listener, final GlobalStateInfo globalInfo,
22 | SearchFilter searchFilter,
23 | ConcurrentMap blacklist,
24 | Set pickedList) throws SQLException;
25 | }
26 |
--------------------------------------------------------------------------------
/src/main/java/com/oceanbase/jdbc/internal/failover/LoadBalanceStrategy/RandomStrategy.java:
--------------------------------------------------------------------------------
1 | package com.oceanbase.jdbc.internal.failover.LoadBalanceStrategy;
2 |
3 | import java.sql.SQLException;
4 | import java.util.Collections;
5 | import java.util.List;
6 | import java.util.Set;
7 | import java.util.concurrent.ConcurrentMap;
8 |
9 | import com.oceanbase.jdbc.HostAddress;
10 | import com.oceanbase.jdbc.UrlParser;
11 | import com.oceanbase.jdbc.internal.failover.Listener;
12 | import com.oceanbase.jdbc.internal.failover.impl.LoadBalanceAddressList;
13 | import com.oceanbase.jdbc.internal.failover.tools.SearchFilter;
14 | import com.oceanbase.jdbc.internal.failover.utils.HostStateInfo;
15 | import com.oceanbase.jdbc.internal.logging.Logger;
16 | import com.oceanbase.jdbc.internal.logging.LoggerFactory;
17 | import com.oceanbase.jdbc.internal.protocol.MasterProtocol;
18 | import com.oceanbase.jdbc.internal.util.pool.GlobalStateInfo;
19 |
20 | public class RandomStrategy implements BalanceStrategy {
21 | private static final Logger logger = LoggerFactory.getLogger(RandomStrategy.class);
22 |
23 | public RandomStrategy() {
24 | }
25 |
26 | @Override
27 | public String toString() {
28 | return "RandomStrategy{}";
29 | }
30 |
31 | public String toJson() {
32 | return "\"OBLB_STRATEGY\":\"RANDOM\"";
33 | }
34 |
35 | @Override
36 | public void pickConnection(LoadBalanceAddressList loadBalanceAddressList, UrlParser urlParser,
37 | Listener listener, GlobalStateInfo globalInfo,
38 | SearchFilter searchFilter,
39 | ConcurrentMap blacklist,
40 | Set pickedList) throws SQLException {
41 |
42 | List loopAddress = loadBalanceAddressList.convertToHostAddressList();
43 | if (BalanceStrategy.allBlack(loopAddress, blacklist)) {
44 | throw new SQLException("No active connection found for master");
45 | } else {
46 | // remove hosts which have been added to blacklist(but not grey list) in previous groups from current group
47 | for (HostAddress hostAddress : blacklist.keySet()) {
48 | if (loopAddress.contains(hostAddress)
49 | && blacklist.get(hostAddress).getState() == HostStateInfo.STATE.BLACK) {
50 | loopAddress.remove(hostAddress);
51 | }
52 | }
53 | }
54 | Collections.shuffle(loopAddress);
55 | logger.debug("Current black list : " + blacklist);
56 | logger.debug("Picked list : " + pickedList);
57 | logger.debug("LoopAddress : " + loopAddress);
58 |
59 | MasterProtocol.loop(listener, globalInfo, loopAddress);
60 | }
61 |
62 | public void pickConnectionFallThrough(LoadBalanceAddressList loadBalanceAddressList,
63 | Listener listener, GlobalStateInfo globalInfo)
64 | throws SQLException {
65 | List loopAddress = loadBalanceAddressList.convertToHostAddressList();
66 | Collections.shuffle(loopAddress);
67 | logger.debug("LoopAddress : " + loopAddress);
68 | MasterProtocol.loop(listener, globalInfo, loopAddress, true);
69 | }
70 | }
71 |
--------------------------------------------------------------------------------
/src/main/java/com/oceanbase/jdbc/internal/failover/LoadBalanceStrategy/RotationStrategy.java:
--------------------------------------------------------------------------------
1 | package com.oceanbase.jdbc.internal.failover.LoadBalanceStrategy;
2 |
3 | import java.sql.SQLException;
4 | import java.util.List;
5 | import java.util.Set;
6 | import java.util.concurrent.ConcurrentMap;
7 |
8 | import com.oceanbase.jdbc.HostAddress;
9 | import com.oceanbase.jdbc.UrlParser;
10 | import com.oceanbase.jdbc.internal.failover.Listener;
11 | import com.oceanbase.jdbc.internal.failover.impl.LoadBalanceAddressList;
12 | import com.oceanbase.jdbc.internal.failover.tools.SearchFilter;
13 | import com.oceanbase.jdbc.internal.failover.utils.HostStateInfo;
14 | import com.oceanbase.jdbc.internal.logging.Logger;
15 | import com.oceanbase.jdbc.internal.logging.LoggerFactory;
16 | import com.oceanbase.jdbc.internal.protocol.MasterProtocol;
17 | import com.oceanbase.jdbc.internal.util.pool.GlobalStateInfo;
18 |
19 | public class RotationStrategy implements BalanceStrategy {
20 | private static final Logger logger = LoggerFactory.getLogger(RotationStrategy.class);
21 |
22 | public RotationStrategy() {
23 |
24 | }
25 |
26 | @Override
27 | public String toString() {
28 | return "RotationStrategy{}";
29 | }
30 |
31 | public String toJson() {
32 | return "\"OBLB_STRATEGY\":\"ROTATION\"";
33 | }
34 |
35 | @Override
36 | public void pickConnection(LoadBalanceAddressList loadBalanceAddressList, UrlParser urlParser,
37 | Listener listener, GlobalStateInfo globalInfo,
38 | SearchFilter searchFilter,
39 | ConcurrentMap blacklist,
40 | Set pickedList) throws SQLException {
41 | List loopAddress = loadBalanceAddressList.convertToHostAddressList();
42 | if (BalanceStrategy.allBlack(loopAddress, blacklist)) {
43 | throw new SQLException("No active connection found for master");
44 | } else {
45 | // remove hosts which have been added to blacklist(but not grey list) in previous groups from current group
46 | for (HostAddress hostAddress : blacklist.keySet()) {
47 | if (loopAddress.contains(hostAddress)
48 | && blacklist.get(hostAddress).getState() == HostStateInfo.STATE.BLACK) {
49 | loopAddress.remove(hostAddress);
50 | }
51 | }
52 | }
53 | logger.debug("Current black list : " + blacklist);
54 | logger.debug("LoopAddress : " + loopAddress);
55 | MasterProtocol.loop(listener, globalInfo, loopAddress);
56 | }
57 |
58 | public void pickConnectionFallThrough(LoadBalanceAddressList loadBalanceAddressList,
59 | Listener listener, GlobalStateInfo globalInfo)
60 | throws SQLException {
61 | List loopAddress = loadBalanceAddressList.convertToHostAddressList();
62 | logger.debug("LoopAddress : " + loopAddress);
63 | MasterProtocol.loop(listener, globalInfo, loopAddress, true);
64 | }
65 | }
66 |
--------------------------------------------------------------------------------
/src/main/java/com/oceanbase/jdbc/internal/failover/impl/LoadBalanceHostAddress.java:
--------------------------------------------------------------------------------
1 | package com.oceanbase.jdbc.internal.failover.impl;
2 |
3 | import com.oceanbase.jdbc.HostAddress;
4 |
5 | public class LoadBalanceHostAddress extends HostAddress {
6 | private int weight;
7 |
8 | public LoadBalanceHostAddress(String host, int port) {
9 | super(host, port);
10 | }
11 |
12 | public LoadBalanceHostAddress(String host, int port, int weight) {
13 | super(host, port);
14 | this.weight = weight;
15 | }
16 |
17 | public LoadBalanceHostAddress(String host, int port, String type) {
18 | super(host, port, type);
19 | }
20 |
21 | @Override
22 | public String toString() {
23 | return "LoadBalanceHostAddress{" + "weight=" + weight + ", host='" + host + '\''
24 | + ", port=" + port + ", type='" + type + '\'' + '}';
25 | }
26 |
27 | public String toJson() {
28 | StringBuilder json = new StringBuilder("\"HOST\":\"" + host + "\",\"PORT\":" + port);
29 | if (weight > 0) {
30 | json.append(",\"WEIGHT\":").append(weight);
31 | }
32 | return json.toString();
33 | }
34 |
35 | public void setWeight(int weight) {
36 | this.weight = weight;
37 | }
38 |
39 | public int getWeight() {
40 | return weight;
41 | }
42 |
43 | }
44 |
--------------------------------------------------------------------------------
/src/main/java/com/oceanbase/jdbc/internal/failover/impl/checkers/BalanceStrategyChecker.java:
--------------------------------------------------------------------------------
1 | package com.oceanbase.jdbc.internal.failover.impl.checkers;
2 |
3 | import java.util.Arrays;
4 | import java.util.HashMap;
5 | import java.util.HashSet;
6 |
7 | public class BalanceStrategyChecker implements ConfigChecker {
8 | HashSet keySet = new HashSet<>(Arrays.asList("NAME"));
9 |
10 | HashSet namesSet = new HashSet<>(Arrays.asList("ROTATION","RANDOM","SERVERAFFINITY","DEFAULT"));
11 | @Override
12 | public boolean isValid(HashMap config) {
13 | return keySet.containsAll(config.keySet()) && namesSet.contains(config.get("NAME"));
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/src/main/java/com/oceanbase/jdbc/internal/failover/impl/checkers/BlackListStrategyAppendChecker.java:
--------------------------------------------------------------------------------
1 | package com.oceanbase.jdbc.internal.failover.impl.checkers;
2 |
3 | import java.util.Arrays;
4 | import java.util.HashMap;
5 | import java.util.HashSet;
6 |
7 | public class BlackListStrategyAppendChecker implements ConfigChecker {
8 | HashSet keySet = new HashSet<>(Arrays.asList("NAME","RETRYTIMES","DURATION"));
9 | HashSet namesSet = new HashSet<>(Arrays.asList("RETRYDURATION","NORMAL"));
10 | @Override
11 | public boolean isValid(HashMap config) {
12 | if( keySet.containsAll(config.keySet()) && namesSet.contains(config.get("NAME")) ){
13 | if(config.get("NAME") == "RETRYDURATION") {
14 | String retrytimes = config.get("RETRYTIMES");
15 | try {
16 | int t = Integer.parseInt(retrytimes);
17 | if (t < 0) {
18 | return false;
19 | }
20 | } catch (NumberFormatException e) {
21 | return false;
22 | }
23 | String duration = config.get("DURATION");
24 | try {
25 | int t = Integer.parseInt(duration);
26 | if (t < 0) {
27 | return false;
28 | } else {
29 | return true;
30 | }
31 | } catch (NumberFormatException e) {
32 | return false;
33 | }
34 | } else {
35 | return true;
36 | }
37 | }
38 | return false;
39 | }
40 | }
41 |
--------------------------------------------------------------------------------
/src/main/java/com/oceanbase/jdbc/internal/failover/impl/checkers/BlackListStrategyRemoveChecker.java:
--------------------------------------------------------------------------------
1 | package com.oceanbase.jdbc.internal.failover.impl.checkers;
2 |
3 | import java.util.Arrays;
4 | import java.util.HashMap;
5 | import java.util.HashSet;
6 |
7 | public class BlackListStrategyRemoveChecker implements ConfigChecker {
8 | HashSet keySet = new HashSet<>(Arrays.asList("NAME","TIMEOUT"));
9 | HashSet namesSet = new HashSet<>(Arrays.asList("TIMEOUT"));
10 | @Override
11 | public boolean isValid(HashMap config) {
12 | if(keySet.containsAll(config.keySet()) && namesSet.contains(config.get("NAME")) ){
13 | String timeout = config.get("TIMEOUT");
14 | try {
15 | int t = Integer.parseInt(timeout);
16 | if(t<0) {
17 | return false;
18 | } else {
19 | return true;
20 | }
21 | } catch (NumberFormatException e) {
22 | return false;
23 | }
24 | }
25 | return false;
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/src/main/java/com/oceanbase/jdbc/internal/failover/impl/checkers/ConfigChecker.java:
--------------------------------------------------------------------------------
1 | package com.oceanbase.jdbc.internal.failover.impl.checkers;
2 |
3 | import java.util.HashMap;
4 |
5 | public interface ConfigChecker {
6 | boolean isValid(HashMap config);
7 | }
8 |
--------------------------------------------------------------------------------
/src/main/java/com/oceanbase/jdbc/internal/failover/impl/checkers/GroupStrategyConfigChecker.java:
--------------------------------------------------------------------------------
1 | package com.oceanbase.jdbc.internal.failover.impl.checkers;
2 |
3 | import java.util.*;
4 | import java.util.HashSet;
5 |
6 | import com.oceanbase.jdbc.internal.failover.impl.checkers.ConfigChecker;
7 |
8 | public class GroupStrategyConfigChecker implements ConfigChecker {
9 | HashSet keySet = new HashSet<>(Arrays.asList("NAME"));
10 | HashSet namesSet = new HashSet<>(Arrays.asList("ROTATION"));
11 |
12 |
13 | @Override
14 | public boolean isValid(HashMap config) {
15 | return keySet.containsAll(config.keySet()) && namesSet.contains(config.get("NAME"));
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/src/main/java/com/oceanbase/jdbc/internal/failover/utils/Consts.java:
--------------------------------------------------------------------------------
1 | package com.oceanbase.jdbc.internal.failover.utils;
2 |
3 | public class Consts {
4 | // configure
5 | public static final String NAME = "NAME";
6 | public static final String RETRYTIMES = "RETRYTIMES";
7 | public static final String DURATION_MS = "DURATION";
8 | public static final String TIMEOUT_MS = "TIMEOUT";
9 | public static final String RETRYDURATION = "RETRYDURATION";
10 | public static final String NORMAL = "NORMAL";
11 | public static final String SERVERAFFINITY = "SERVERAFFINITY";
12 | public static final String ROTATION = "ROTATION";
13 | public static final String RANDOM = "RANDOM";
14 | public static final String ON = "ON";
15 | public static final String DEFAULT = "DEFAULT";
16 |
17 | // blacklist
18 | public static final String FAILED_TIME_MS = "failedTime";
19 |
20 | }
21 |
--------------------------------------------------------------------------------
/src/main/java/com/oceanbase/jdbc/internal/failover/utils/HostStateInfo.java:
--------------------------------------------------------------------------------
1 | package com.oceanbase.jdbc.internal.failover.utils;
2 |
3 | public class HostStateInfo {
4 | public enum STATE {
5 | GREY,
6 | BLACK
7 | }
8 |
9 | STATE state;
10 | Long timestamp;
11 |
12 | public HostStateInfo() {
13 | state = STATE.BLACK;
14 | timestamp = System.nanoTime();
15 | }
16 |
17 | public HostStateInfo(STATE state, Long timestamp) {
18 | this.state = state;
19 | this.timestamp = timestamp;
20 | }
21 |
22 | public STATE getState() {
23 | return state;
24 | }
25 |
26 | public void setState(STATE state) {
27 | this.state = state;
28 | }
29 |
30 | public Long getTimestamp() {
31 | return timestamp;
32 | }
33 |
34 | public void setTimestamp(Long timestamp) {
35 | this.timestamp = timestamp;
36 | }
37 |
38 | @Override
39 | public String toString() {
40 | return "HostStateInfo{" + "state=" + state + ", timestamp=" + timestamp + '}';
41 | }
42 | }
43 |
--------------------------------------------------------------------------------
/src/main/java/com/oceanbase/jdbc/internal/io/socket/SocketHandlerFunction.java:
--------------------------------------------------------------------------------
1 | /**
2 | * OceanBase Client for Java
3 | *
4 | * Copyright (c) 2012-2014 Monty Program Ab.
5 | * Copyright (c) 2015-2020 MariaDB Corporation Ab.
6 | * Copyright (c) 2021 OceanBase.
7 | *
8 | * This library is free software; you can redistribute it and/or modify it under
9 | * the terms of the GNU Lesser General Public License as published by the Free
10 | * Software Foundation; either version 2.1 of the License, or (at your option)
11 | * any later version.
12 | *
13 | * This library is distributed in the hope that it will be useful, but
14 | * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
15 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
16 | * for more details.
17 | *
18 | * You should have received a copy of the GNU Lesser General Public License along
19 | * with this library; if not, write to Monty Program Ab info@montyprogram.com.
20 | *
21 | * This particular MariaDB Client for Java file is work
22 | * derived from a Drizzle-JDBC. Drizzle-JDBC file which is covered by subject to
23 | * the following copyright and notice provisions:
24 | *
25 | * Copyright (c) 2009-2011, Marcus Eriksson
26 | *
27 | * Redistribution and use in source and binary forms, with or without modification,
28 | * are permitted provided that the following conditions are met:
29 | * Redistributions of source code must retain the above copyright notice, this list
30 | * of conditions and the following disclaimer.
31 | *
32 | * Redistributions in binary form must reproduce the above copyright notice, this
33 | * list of conditions and the following disclaimer in the documentation and/or
34 | * other materials provided with the distribution.
35 | *
36 | * Neither the name of the driver nor the names of its contributors may not be
37 | * used to endorse or promote products derived from this software without specific
38 | * prior written permission.
39 | *
40 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
41 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
42 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
43 | * IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
44 | * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
45 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
46 | * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
47 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
48 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
49 | * OF SUCH DAMAGE.
50 | */
51 | package com.oceanbase.jdbc.internal.io.socket;
52 |
53 | import java.io.IOException;
54 | import java.net.Socket;
55 |
56 | import com.oceanbase.jdbc.util.Options;
57 |
58 | @FunctionalInterface
59 | public interface SocketHandlerFunction {
60 |
61 | Socket apply(Options options, String host) throws IOException;
62 | }
63 |
--------------------------------------------------------------------------------
/src/main/java/com/oceanbase/jdbc/internal/util/BulkStatus.java:
--------------------------------------------------------------------------------
1 | /**
2 | * OceanBase Client for Java
3 | *
4 | * Copyright (c) 2012-2014 Monty Program Ab.
5 | * Copyright (c) 2015-2020 MariaDB Corporation Ab.
6 | * Copyright (c) 2021 OceanBase.
7 | *
8 | * This library is free software; you can redistribute it and/or modify it under
9 | * the terms of the GNU Lesser General Public License as published by the Free
10 | * Software Foundation; either version 2.1 of the License, or (at your option)
11 | * any later version.
12 | *
13 | * This library is distributed in the hope that it will be useful, but
14 | * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
15 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
16 | * for more details.
17 | *
18 | * You should have received a copy of the GNU Lesser General Public License along
19 | * with this library; if not, write to Monty Program Ab info@montyprogram.com.
20 | *
21 | * This particular MariaDB Client for Java file is work
22 | * derived from a Drizzle-JDBC. Drizzle-JDBC file which is covered by subject to
23 | * the following copyright and notice provisions:
24 | *
25 | * Copyright (c) 2009-2011, Marcus Eriksson
26 | *
27 | * Redistribution and use in source and binary forms, with or without modification,
28 | * are permitted provided that the following conditions are met:
29 | * Redistributions of source code must retain the above copyright notice, this list
30 | * of conditions and the following disclaimer.
31 | *
32 | * Redistributions in binary form must reproduce the above copyright notice, this
33 | * list of conditions and the following disclaimer in the documentation and/or
34 | * other materials provided with the distribution.
35 | *
36 | * Neither the name of the driver nor the names of its contributors may not be
37 | * used to endorse or promote products derived from this software without specific
38 | * prior written permission.
39 | *
40 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
41 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
42 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
43 | * IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
44 | * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
45 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
46 | * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
47 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
48 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
49 | * OF SUCH DAMAGE.
50 | */
51 | package com.oceanbase.jdbc.internal.util;
52 |
53 | public class BulkStatus {
54 |
55 | public volatile int sendSubCmdCounter;
56 | public volatile boolean sendEnded;
57 | public int sendCmdCounter = 0;
58 | }
59 |
--------------------------------------------------------------------------------
/src/main/java/com/oceanbase/jdbc/internal/util/ConnectionState.java:
--------------------------------------------------------------------------------
1 | /**
2 | * OceanBase Client for Java
3 | *
4 | * Copyright (c) 2012-2014 Monty Program Ab.
5 | * Copyright (c) 2015-2020 MariaDB Corporation Ab.
6 | * Copyright (c) 2021 OceanBase.
7 | *
8 | * This library is free software; you can redistribute it and/or modify it under
9 | * the terms of the GNU Lesser General Public License as published by the Free
10 | * Software Foundation; either version 2.1 of the License, or (at your option)
11 | * any later version.
12 | *
13 | * This library is distributed in the hope that it will be useful, but
14 | * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
15 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
16 | * for more details.
17 | *
18 | * You should have received a copy of the GNU Lesser General Public License along
19 | * with this library; if not, write to Monty Program Ab info@montyprogram.com.
20 | *
21 | * This particular MariaDB Client for Java file is work
22 | * derived from a Drizzle-JDBC. Drizzle-JDBC file which is covered by subject to
23 | * the following copyright and notice provisions:
24 | *
25 | * Copyright (c) 2009-2011, Marcus Eriksson
26 | *
27 | * Redistribution and use in source and binary forms, with or without modification,
28 | * are permitted provided that the following conditions are met:
29 | * Redistributions of source code must retain the above copyright notice, this list
30 | * of conditions and the following disclaimer.
31 | *
32 | * Redistributions in binary form must reproduce the above copyright notice, this
33 | * list of conditions and the following disclaimer in the documentation and/or
34 | * other materials provided with the distribution.
35 | *
36 | * Neither the name of the driver nor the names of its contributors may not be
37 | * used to endorse or promote products derived from this software without specific
38 | * prior written permission.
39 | *
40 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
41 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
42 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
43 | * IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
44 | * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
45 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
46 | * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
47 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
48 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
49 | * OF SUCH DAMAGE.
50 | */
51 | package com.oceanbase.jdbc.internal.util;
52 |
53 | public class ConnectionState {
54 |
55 | public static final int STATE_NETWORK_TIMEOUT = 1;
56 | public static final int STATE_DATABASE = 2;
57 | public static final int STATE_READ_ONLY = 4;
58 | public static final int STATE_AUTOCOMMIT = 8;
59 | public static final int STATE_TRANSACTION_ISOLATION = 16;
60 | }
61 |
--------------------------------------------------------------------------------
/src/main/java/com/oceanbase/jdbc/internal/util/DeRegister.java:
--------------------------------------------------------------------------------
1 | /**
2 | * OceanBase Client for Java
3 | *
4 | * Copyright (c) 2012-2014 Monty Program Ab.
5 | * Copyright (c) 2015-2020 MariaDB Corporation Ab.
6 | * Copyright (c) 2021 OceanBase.
7 | *
8 | * This library is free software; you can redistribute it and/or modify it under
9 | * the terms of the GNU Lesser General Public License as published by the Free
10 | * Software Foundation; either version 2.1 of the License, or (at your option)
11 | * any later version.
12 | *
13 | * This library is distributed in the hope that it will be useful, but
14 | * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
15 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
16 | * for more details.
17 | *
18 | * You should have received a copy of the GNU Lesser General Public License along
19 | * with this library; if not, write to Monty Program Ab info@montyprogram.com.
20 | *
21 | * This particular MariaDB Client for Java file is work
22 | * derived from a Drizzle-JDBC. Drizzle-JDBC file which is covered by subject to
23 | * the following copyright and notice provisions:
24 | *
25 | * Copyright (c) 2009-2011, Marcus Eriksson
26 | *
27 | * Redistribution and use in source and binary forms, with or without modification,
28 | * are permitted provided that the following conditions are met:
29 | * Redistributions of source code must retain the above copyright notice, this list
30 | * of conditions and the following disclaimer.
31 | *
32 | * Redistributions in binary form must reproduce the above copyright notice, this
33 | * list of conditions and the following disclaimer in the documentation and/or
34 | * other materials provided with the distribution.
35 | *
36 | * Neither the name of the driver nor the names of its contributors may not be
37 | * used to endorse or promote products derived from this software without specific
38 | * prior written permission.
39 | *
40 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
41 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
42 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
43 | * IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
44 | * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
45 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
46 | * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
47 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
48 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
49 | * OF SUCH DAMAGE.
50 | */
51 | package com.oceanbase.jdbc.internal.util;
52 |
53 | import java.sql.DriverAction;
54 |
55 | import com.oceanbase.jdbc.internal.util.scheduler.SchedulerServiceProviderHolder;
56 |
57 | public class DeRegister implements DriverAction {
58 |
59 | @Override
60 | public void deregister() {
61 | SchedulerServiceProviderHolder.close();
62 | }
63 | }
64 |
--------------------------------------------------------------------------------
/src/main/java/com/oceanbase/jdbc/internal/util/LRUCache.java:
--------------------------------------------------------------------------------
1 | /**
2 | * OceanBase Client for Java
3 | *
4 | * Copyright (c) 2012-2014 Monty Program Ab.
5 | * Copyright (c) 2015-2020 MariaDB Corporation Ab.
6 | * Copyright (c) 2021 OceanBase.
7 | *
8 | * This library is free software; you can redistribute it and/or modify it under
9 | * the terms of the GNU Lesser General Public License as published by the Free
10 | * Software Foundation; either version 2.1 of the License, or (at your option)
11 | * any later version.
12 | *
13 | * This library is distributed in the hope that it will be useful, but
14 | * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
15 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
16 | * for more details.
17 | *
18 | * You should have received a copy of the GNU Lesser General Public License along
19 | * with this library; if not, write to Monty Program Ab info@montyprogram.com.
20 | *
21 | * This particular MariaDB Client for Java file is work
22 | * derived from a Drizzle-JDBC. Drizzle-JDBC file which is covered by subject to
23 | * the following copyright and notice provisions:
24 | *
25 | * Copyright (c) 2009-2011, Marcus Eriksson
26 | *
27 | * Redistribution and use in source and binary forms, with or without modification,
28 | * are permitted provided that the following conditions are met:
29 | * Redistributions of source code must retain the above copyright notice, this list
30 | * of conditions and the following disclaimer.
31 | *
32 | * Redistributions in binary form must reproduce the above copyright notice, this
33 | * list of conditions and the following disclaimer in the documentation and/or
34 | * other materials provided with the distribution.
35 | *
36 | * Neither the name of the driver nor the names of its contributors may not be
37 | * used to endorse or promote products derived from this software without specific
38 | * prior written permission.
39 | *
40 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
41 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
42 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
43 | * IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
44 | * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
45 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
46 | * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
47 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
48 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
49 | * OF SUCH DAMAGE.
50 | */
51 | package com.oceanbase.jdbc.internal.util;
52 |
53 | import java.util.LinkedHashMap;
54 | import java.util.Map;
55 |
56 | public class LRUCache extends LinkedHashMap