This topic describes how to connect a Druid database to DLA.
package demo;
import com.alibaba.druid.pool.DruidDataSource;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
public class DLAJavaDemo {
public static void main(String[] args) throws SQLException {
DruidDataSource dds = new DruidDataSource();
dds.setUrl("jdbc:mysql://<Prefix of the DLA endpoint>. .datalakeanalytics.aliyuncs.com:10000");
dds.setUsername("<DLA username>");
dds.setPassword("<DLA password>");
dds.setMinIdle(1);
dds.setInitialSize(1);
dds.setMaxActive(10);
dds.setXxx()
try (Connection c = dds.getConnection()) {
try (Statement s = c.createStatement()) {
try (ResultSet rs = s.executeQuery("select * from your_dla_schema.your_dla_table")) {
while (rs.next()) {
System.out.println(rs.getObject(1));
}
}
}
}
}
}
For more configurations, see DruidDataSource.