1,pom中引入
<dependency>
<groupId>org.apache.calcite.avatica</groupId>
<artifactId>avatica-core</artifactId>
<version>1.15.0</version>
</dependency>
2,
public class DruidJdbcUtil {
public static AvaticaConnection connection() throws SQLException{
String urlStr = "jdbc:avatica:remote:url="【http://ip:8082】/druid/v2/sql/avatica/";
Properties connectionProperties = new Properties();
AvaticaConnection connection = DriverManager.getConnection(urlStr, connectionProperties);
AvaticaStatement statement = connection.createStatement();
ResultSet resultSet = statement.executeQuery(sql);
while (resultSet.next()) {
String aa = resultSet.getString("aaa);
......
}
}
}