使用以下代碼片段從一個筆記本
% scala java.sql進口。連接導入java.sql。DriverManager java.sql進口。ResultSet java.sql進口。SQLException / * * *有關這個查詢是什麼意思,結帳https://dev.mysql.com/doc/refman/8.0/en/processlist-table.html* * / def printConnections:單位= {val metastoreURL = spark.sparkContext.hadoopConfiguration.get (“javax.jdo.option.ConnectionURL”) val metastoreUser = spark.sparkContext.hadoopConfiguration.get (“javax.jdo.option.ConnectionUserName”) val metastorePassword = spark.sparkContext.hadoopConfiguration.get (javax.jdo.option.ConnectionPassword) = DriverManager val連接。getConnection (metastoreURL、metastoreUser metastorePassword) = connection.createStatement val聲明()val resultSet =聲明。從INFORMATION_SCHEMA executeQuery (“SELECT *。PROCESSLIST ORDER BY主機”)val rsmd = resultSet.getMetaData ();val columnsNumber = rsmd.getColumnCount ();columnsNumber (1)。foreach{我= >打印(rsmd.getColumnName(我)+ " \ t \ t \ \ \ t \ \ t”)} println ();而(resultSet.next ()) {var cumulativeLength = 0 columnsNumber (1)。foreach{我= = > val數據如果(resultSet.getString(我)! = null) resultSet.getString (i) .trim()其他“打印(數據+“t \ \ t \ t \ \ \ t”);}println ();}的聲明。關閉連接。close } printConnections
使用以下代碼片段從一個筆記本
% scala java.sql進口。連接導入java.sql。DriverManager java.sql進口。ResultSet java.sql進口。SQLException / * * *有關這個查詢是什麼意思,結帳https://dev.mysql.com/doc/refman/8.0/en/processlist-table.html* * / def printConnections:單位= {val metastoreURL = spark.sparkContext.hadoopConfiguration.get (“javax.jdo.option.ConnectionURL”) val metastoreUser = spark.sparkContext.hadoopConfiguration.get (“javax.jdo.option.ConnectionUserName”) val metastorePassword = spark.sparkContext.hadoopConfiguration.get (javax.jdo.option.ConnectionPassword) = DriverManager val連接。getConnection (metastoreURL、metastoreUser metastorePassword) = connection.createStatement val聲明()val resultSet =聲明。從INFORMATION_SCHEMA executeQuery (“SELECT *。PROCESSLIST ORDER BY主機”)val rsmd = resultSet.getMetaData ();val columnsNumber = rsmd.getColumnCount ();columnsNumber (1)。foreach{我= >打印(rsmd.getColumnName(我)+ " \ t \ t \ \ \ t \ \ t”)} println ();而(resultSet.next ()) {var cumulativeLength = 0 columnsNumber (1)。foreach{我= = > val數據如果(resultSet.getString(我)! = null) resultSet.getString (i) .trim()其他“打印(數據+“t \ \ t \ t \ \ \ t”);}println ();}的聲明。關閉連接。close } printConnections