Java DatabaseMetaData get pseudo-columns

Description

Java DatabaseMetaData get pseudo-columns

import java.sql.Connection;
import java.sql.DatabaseMetaData;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;

public class Main {
   public static void main(String[] args) {
      try {//from   w  ww  .j  av  a  2 s  .  c o  m
         Connection con = DriverManager.getConnection("jdbc:derby://localhost:1527/contact", "userName", "password");
         DatabaseMetaData metaData = con.getMetaData();
         ResultSet resultSet = metaData.getPseudoColumns("", "schemaName", "tableName", "");

         while (resultSet.next()) {
            System.out.println(resultSet.getString("TABLE_SCHEM ") 
                  + " - " + resultSet.getString("COLUMN_NAME "));
         }

      } catch (SQLException ex) {
         ex.printStackTrace();
      }

   }

}



PreviousNext

Related