Skip to content

Instantly share code, notes, and snippets.

@ikiw
Last active August 29, 2015 14:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ikiw/bf32ad4f45bd57ddaf04 to your computer and use it in GitHub Desktop.
Save ikiw/bf32ad4f45bd57ddaf04 to your computer and use it in GitHub Desktop.
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