how to get all the columns of a specific table ucanaccess [duplicate]

孤者浪人 提交于 2019-12-12 03:28:14

问题


I want to get all the column names for a specific table called Impedance2, in an Access database I have. I can only seem to get column metadata I think rather than the actual name:

This is the code I am using:

DatabaseMetaData md = conn.getMetaData();
                        ResultSet rst = md.getTables(null, null, "Impedance2", null);
                        ResultSetMetaData rsmd = rst.getMetaData();
                        System.out.println("Column names as reported by ResultSetMetaData:");
                        for (int i = 1; i <= rsmd.getColumnCount(); i++) {
                            System.out.println("Col"+rsmd.getColumnName(i));
                        }

This is the result I am getting:

ColTABLE_CAT
ColTABLE_SCHEM
ColTABLE_NAME
ColTABLE_TYPE
ColREMARKS
ColTYPE_CAT
ColTYPE_SCHEM
ColTYPE_NAME
ColSELF_REFERENCING_COL_NAME
ColREF_GENERATION
ColHSQLDB_TYPE
ColREAD_ONLY
ColCOMMIT_ACTION

回答1:


You're asking for a resultset of tables with their attributes. If you read the metadata of this resultset you'll get the metadata of metadata. Use getColumns to get the table column names and just read the resultset.



来源:https://stackoverflow.com/questions/36931666/how-to-get-all-the-columns-of-a-specific-table-ucanaccess

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!