In postgresql a query in the querylog gets something like this:
2009-02-05 00:12:27 CET LOG: duration: 3781.634 ms execute <unnamed>: SELECT QUERY ....
Is there a possibility to put something more usable into the "< unnamed >" placed like the url the query was requested from?
Are there any other possibilities to track the origin of a query in postgresql using jdbc from java?
Thanks
The syntax to rename a column in a table in PostgreSQL (using the ALTER TABLE statement) is: ALTER TABLE table_name RENAME COLUMN old_name TO new_name; table_name. The name of the table to modify.
If you want to select data from all the columns of the table, you can use an asterisk ( * ) shorthand instead of specifying all the column names. The select list may also contain expressions or literal values. Second, specify the name of the table from which you want to query data after the FROM keyword.
Summary. Assign a column or an expression a column alias using the syntax column_name AS alias_name or expression AS alias_name . The AS keyword is optional. Use double quotes (“) to surround a column alias that contains spaces.
Short answer is "no"
The name can be set when preparing the statement, using the PREPARE command, but that requires rewriting all your SQL. There is no option to simply add a name parameter to your JDBC methods.
The JDBC driver makes use of both named and unnamed prepared statements. It will give them a name when it wishes to reuse them, which it will deem appropriate if the same PreparedStatement object is executed 5 times (though that is configurable through setting the prepareThreshold).
Documentation is here
More info can also be found by searching the PostgreSQL JDBC mailling list
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With