Task Submission And Execution Of JDBC API Documents

    1. Enter the ujes/jdbc directory in the Linkis project and enter the command in the terminal to package mvn assembly:assembly -Dmaven.test.skip=true The packaging instruction skips the running of the unit test and the compilation of the test code, and packages the dependencies required by the JDBC module into the Jar package.
    2. After the packaging is complete, two Jar packages will be generated in the target directory of JDBC. The one with dependencies in the Jar package name is the Jar package we need.

    2. Create A Test Category

    1. public static void main(String[] args) throws SQLException, ClassNotFoundException {
    2. //1. Load driver class:org.apache.linkis.ujes.jdbc.UJESSQLDriver
    3. Class.forName("org.apache.linkis.ujes.jdbc.UJESSQLDriver");
    4. //2. Get connection:jdbc:linkis://gatewayIP:gatewayPort
    5. Connection connection = DriverManager.getConnection("jdbc:linkis://127.0.0.1:9001","username","password");
    6. //3. Create statement and execute query
    7. Statement st= connection.createStatement();
    8. ResultSet rs=st.executeQuery("show tables");
    9. //4. Processing the returned results of the database (using the ResultSet class)
    10. while (rs.next()) {
    11. System.out.print(metaData.getColumnName(i) + ":" +metaData.getColumnTypeName(i)+": "+ rs.getObject(i) + " ");
    12. }
    13. System.out.println();
    14. }
    15. // close resourse
    16. rs.close();
    17. st.close();
    18. connection.close();
    19. }