The first way depends on the JDBC module in the pom:
<dependency> <groupId>org.apache.linkis</groupId> <artifactId>linkis-ujes-jdbc</artifactId> <version>${linkis.version}</version> </dependency>
Note: The module has not been deployed to the central repository. You need to execute mvn install -Dmaven.test.skip=true in the ujes/jdbc directory for local installation.
The second way is through packaging and compilation:
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.Establish a Java test class LinkisClientImplTestJ, the specific interface meaning can be seen in the notes:
public static void main(String[] args) throws SQLException, ClassNotFoundException { //1. Load driver class:org.apache.linkis.ujes.jdbc.UJESSQLDriver Class.forName("org.apache.linkis.ujes.jdbc.UJESSQLDriver"); //2. Get connection:jdbc:linkis://gatewayIP:gatewayPort // the front-end account password Connection connection = DriverManager.getConnection("jdbc:linkis://127.0.0.1:9001","username","password"); //3. Create statement and execute query Statement st= connection.createStatement(); ResultSet rs=st.executeQuery("show tables"); //4. Processing the returned results of the database (using the ResultSet class) while (rs.next()) { ResultSetMetaData metaData = rs.getMetaData(); for (int i = 1; i <= metaData.getColumnCount(); i++) { System.out.print(metaData.getColumnName(i) + ":" +metaData.getColumnTypeName(i)+": "+ rs.getObject(i) + " "); } System.out.println(); } // close resourse rs.close(); st.close(); connection.close(); }