[英]What is the command to check the version of the postgresql jdbc driver on Linux command line?
I am working on Linux server with PostgreSQL that is installed through the command line.我正在使用通过命令行安装的 PostgreSQL 的 Linux 服务器。
How could I check the version of the PostgreSQL JDBC Driver using Linux command line?如何使用 Linux 命令行检查PostgreSQL JDBC 驱动程序的版本?
I use this command psql -V
and it shows the PostgreSQL version psql (PostgreSQL) 9.5.24
, but I need the PostgreSQL JDBC Driver version.我使用此命令
psql -V
它显示 PostgreSQL 版本psql (PostgreSQL) 9.5.24
,但我需要 PostgreSQL JDBC 驱动程序版本。 What is the command the should I use?我应该使用什么命令?
When you run:当你运行时:
java -jar /path/to/driver.jar
it will report its version.它将报告其版本。
Obviously you need to replace /path/to/driver.jar
with the correct location where you stored the driver when you downloaded it.显然,您需要将
/path/to/driver.jar
替换为下载驱动程序时存储驱动程序的正确位置。
By default the file name itself contains the version.默认情况下,文件名本身包含版本。 So if you downloaded
postgresql-42.2.19.jar
then it's highly likely its version is 42.2.19所以如果你下载了
postgresql-42.2.19.jar
那么它的版本很可能是 42.2.19
As a side note: psql -V
prints the version of the command line tool.附带说明:
psql -V
打印命令行工具的版本。 That's not necessarily the same version as the server.这不一定与服务器的版本相同。
From Java, you can use code like this:从 Java 开始,您可以使用如下代码:
java.sql.Driver d = new org.postgresql.Driver();
System.out.println(d.getMajorVersion() + "." + d.getMinorVersion());
See the documentation for details.有关详细信息,请参阅文档。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.