Last active
August 29, 2015 14:06
-
-
Save ikiw/bf32ad4f45bd57ddaf04 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class GetMetadata { | |
public static void main(String[] args) { | |
try { | |
Class.forName("com.sap.db.jdbc.Driver"); | |
java.sql.Connection conn = java.sql.DriverManager.getConnection("jdbc:sap:host:port", "user", "pwd"); | |
Statement stmt = conn.createStatement(); | |
ResultSet rs = stmt.executeQuery("select * from \"_SYS_BIC\".\"sap.hana.democontent.epm.models/AT_BUYER\""); | |
ResultSetMetaData rsmd = rs.getMetaData(); | |
System.out.println("Total No of Columns:" + rsmd.getTableName(1)); | |
for (int i = 1; i <= rsmd.getColumnCount(); i++) { | |
System.out.print("ColumnName:" + rsmd.getColumnName(i)); | |
System.out.print(" ColumnType:" + rsmd.getColumnTypeName(i)); | |
System.out.println(""); | |
} | |
stmt.close(); | |
conn.close(); | |
} catch (Exception e) { | |
System.out.println("Exception: " + e); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment