Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/devel' into devel
Browse files Browse the repository at this point in the history
  • Loading branch information
serge-rider committed Oct 29, 2024
2 parents 19d4019 + a053c48 commit 0cb1d1d
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,7 @@
import java.io.IOException;
import java.io.InputStream;
import java.net.HttpURLConnection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.SQLFeatureNotSupportedException;
import java.sql.*;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

Expand Down Expand Up @@ -116,4 +113,16 @@ public ResultSet getTables(String catalog, String schemaPattern, String tableNam
}
}

@Override
public ResultSet getColumns(String catalog, String schemaPattern, String tableNamePattern, String columnNamePattern) throws SQLException {
String tableName = tableNamePattern;
try (PreparedStatement dbStat = connection.prepareStatement(
"SELECT NULL as TABLE_CAT, NULL AS TABLE_SCHEM,'" + tableName + "' AS TABLE_NAME," +
"name as COLUMN_NAME," + Types.VARCHAR + " AS DATA_TYPE, type AS TYPE_NAME, 0 AS COLUMN_SIZE," +
"NULL AS REMARKS,cid AS ORDINAL_POSITION " +
"FROM PRAGMA_TABLE_INFO('" + tableName + "')")
) {
return dbStat.executeQuery();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,23 @@ public static void main(String[] args) throws Exception {
printResultSet(dbResult);
}
}
try (Statement dbStat = connection.createStatement()) {
try (ResultSet dbResult = dbStat.executeQuery("select * from PRAGMA_TABLE_INFO('testme')")) {
printResultSet(dbResult);
}
}

System.out.println("Tables:");
try (ResultSet tables = metaData.getTables(null, null, null, null)) {
while (tables.next()) {
String tableName = tables.getString("TABLE_NAME");
System.out.println("\t- " + tableName);
try (ResultSet columns = metaData.getColumns(null, null, tableName, null)) {
while (columns.next()) {
System.out.println("\t\t- " + columns.getString("COLUMN_NAME") + " " + columns.getString("TYPE_NAME"));
}
}

}
}

Expand Down

0 comments on commit 0cb1d1d

Please sign in to comment.