How to connect to 3rd party Postgres from Jira plugin?
What connector can be used in the Jira plugin to connect to Postgres?
I'm new to Java, more details please.
В pox.xml добавил:
<dependency>
<groupId>org.postgresql</groupId>
<artifactId>postgresql</artifactId>
<version>42.2.1</version>
</dependency>
<Import-Package>*;version="0";resolution:=optional</Import-Package>
В классе добавил:
import java.sql.DriverManager;
import java.sql.Connection;
import java.sql.SQLException;
В методе соединяюсь вот так:
String url = "jdbc:postgresql://<host>:<port>/<database>";
String username = "postgres";
String password = "postgres";
Connection conn = null;
try {
conn = DriverManager.getConnection(url, username, password);
System.out.println("Connected to the PostgreSQL server successfully.");
// Успешное соединение
} catch (SQLException e) {
// Не получилось подключиться
System.out.println(e.getMessage());
}
Перезагрузил либы и скомпилировал так:
atlas-package
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.