Parser to parse SQL query and return column name and corresponding table name in Java

Possible duplicate:
SQL parser library for Java

I need a parser that should return me the column names with their corresponding table names in the format

column_name table_name

Preferably a java library that can make the implementation easier, because I do not want to delve into all the nuances of SQL parsing.

Yours faithfully,

+3
source share
2 answers

If you have a database connection, you can do this using a prepared statement:

String sql = "....";
PreparedStatement pstmt = connection.prepareStatement(sql);
ResultSetMetaData meta = pstmt.getMetaData();

ResultSetMetaData.getColumnCount() getColumnName(int) . JDBC , , getTableName(int)

, , , .

+2

All Articles