JDBC DatabaseMetaData.getColumns() returns duplicate columns

前端 未结 5 1333
南方客
南方客 2020-12-15 19:17

I\'m busy on a piece of code to get alle the column names of a table from an Oracle database. The code I came up with looks like this:

DriverManager.register         


        
5条回答
  •  心在旅途
    2020-12-15 20:05

    This doesn't directly answer your question, but another approach is to execute the query:

    select * from tablename where 1 = 0
    

    This will return a ResultSet, even though it doesn't select any rows. The result set metadata will match the table that you selected from. Depending on what you're doing, this can be more convenient. tablename can be anything that you can select on--you don't have to get the case correct or worry about what schema it's in.

提交回复
热议问题