Details
-
Test
-
Status: Resolved
-
Major
-
Resolution: Fixed
-
1.3.0
-
None
-
drill1.3 JDBC SCRIPTS
-
Important
Description
import java.sql.Connection;
import java.sql.Statement;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;
public class MultiThreadTestDrill {
public static void main(String[] args) throws InterruptedException {
int threadNum = 200;
long tStart = System.currentTimeMillis();
System.out.println(Thread.currentThread().getName() + "START");
for (int ii = 0; ii < threadNum; ii++)
while (true) {
if (!WorkerThread.hasThreadRunning())
Thread.sleep(500);
}
System.out.println(Thread.currentThread().getName() + "END");
long tEnd = System.currentTimeMillis();
System.out.println("TOTAL TIME:" + (tEnd - tStart)/1000 + "seconds");
}
public static class WorkerThread extends Thread {
private static List<Thread> runningThreads = new ArrayList<Thread>();
public WorkerThread() {
}
@Override
public void run()
public void regist(Thread t) {
synchronized (runningThreads)
}
public void unRegist(Thread t) {
synchronized (runningThreads)
}
public static boolean hasThreadRunning()
{ return (runningThreads.size() > 0); } private void connectToDrill() {
// TODO Auto-generated method stub
String driver = "org.apache.drill.jdbc.Driver";
String url = "jdbc:drill:drillbit=localhost";
String sql = "SELECT count FROM mysql.datamart.StaticInf";
try {
Class.forName(driver);
// connect drill
Connection conn = (Connection) DriverManager.getConnection(url);
if (!conn.isClosed())
System.out.println("Succeeded connecting to the Drill!");
Statement statement = (Statement) conn.createStatement();
ResultSet rs = statement.executeQuery(sql);
while (rs.next())
{ System.out.println(rs.getString(1)); } rs.close();
conn.close();
} catch (ClassNotFoundException e)
catch (SQLException e)
{ e.printStackTrace(); } catch (Exception e) { e.printStackTrace(); } }
}
}
mysql.datamart.StaticInf has 2144781 rows