请见如下code:获取hana kernel信息 和 license 信息
请 google ‘ngdbc jar’ 或直接下载附件zip包,解压后引用jar包即可 连接hana驱动jar
import java.sql.Connection; import java.sql.ResultSet; import java.sql.SQLException; import java.sql.Statement; static void query_info(String ip, String port, String tename, String user, String password) { String perline = ""; Connection connection = null; String hostname = null; String lisdate = null; String liedate = null; String version = null; String kernel = null; try { Class.forName("com.sap.db.jdbc.Driver"); String url = "jdbc:sap://" + ip + ":" + port + "/" + tename + ""; connection = java.sql.DriverManager.getConnection(url, user, password); System.out.println("Connection done"); } catch (Exception e) { System.err.println(ip + " Connection failed!" + e.getMessage()); } if (connection != null) { try { System.out.println(ip + " Connection to HANA successful!"); // query license start/end date Statement stmt = connection.createStatement(); ResultSet resultSet = stmt.executeQuery("select * from SYS.M_LICENSE "); resultSet.next(); lisdate = resultSet.getString("START_DATE"); liedate = resultSet.getString("EXPIRATION_DATE"); System.out.println(lisdate); System.out.println(liedate); // query version info stmt = connection.createStatement(); resultSet = stmt.executeQuery("select value from SYS.M_SYSTEM_OVERVIEW where name='Version'"); resultSet.next(); version = resultSet.getString("value"); // query kernel info stmt = connection.createStatement(); resultSet = stmt .executeQuery("select host,value from SYS.M_HOST_INFORMATION where key='os_kernel_version'"); resultSet.next(); kernel = resultSet.getString("value"); hostname = resultSet.getString("host"); System.out.println(version); System.out.println(kernel); System.out.println(hostname); resultSet.close(); stmt.close(); connection.close(); } catch (SQLException e) { System.err.println("Query failed!" + e.getMessage()); } } }