How to connect a service to an external database?

database

#1

I’m trying to develop new custom modules for JIRA instance.
For that I need a connection to an external database.
On the code view I have something like that:

private void initConnection()throws SQLException{
    if(this.conn != null && this.conn.isClosed()){
        this.conn.close();
    }
    String host = this.customConfig.getHost()+":"+this.customConfig.getPort();
    String url = "jdbc:postgresql://"+host+"/"+this.customConfig.getDatabase();
    Properties props = new Properties();
    props.setProperty("user",this.customConfig.getUsername());
    props.setProperty("password",this.customConfig.getPassword());
    props.setProperty("ssl","true");
    this.conn = DriverManager.getConnection(url, props);
}

Last line throw this error : java.sql.SQLException: No suitable driver found for jdbc:postgresql://localhost:5432/db-dev
Someone to help me ?


#2

Add the sql driver file to your plugin lib folder or path.


#3

Hi @saurabh.gupta ,

I already try your solution based on https://stackoverflow.com/questions/1911253/the-infamous-java-sql-sqlexception-no-suitable-driver-found but that doesn’t work.

And my Jira server work already with a postgresql database, so the driver is already on it.


#4

Jira has most of the required drivers, but then the questions comes are you able to access that driver.