Connecting Bitbucket plugin to external Oracle database

agugliari January 26, 2016

Hi all,


I'm working in a Bitbucket plugin using Atlassian SDK. My target is Bitbucket version is 4.2.0 

I'm trying to connect the plugin to a external Oracle database, but I'm getting a "oracle.jdbc.OracleDriver not found" exception at runtime (in standalone instance or in my Bitbucket server instance).

I'm trying to get the connection using:

Class.forName("oracle.jdbc.OracleDriver");					
Connection conn = DriverManager.getConnection(CONNECTION_STRING);

When I use my database connection class into another program (not into a plugin) it works fine.

I looked in some pages (into answers.atlassian.com) another ways to import via pom.xml using <import-Pachage> or <dependency> but don't work for me.

Thanks for help

1 answer

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

0 votes
agugliari January 29, 2016

I solved my ploblem using JNI.

My pom.xml 

&lt;build&gt;
       &lt;plugins&gt;
           &lt;plugin&gt;
               &lt;groupId&gt;com.atlassian.maven.plugins&lt;/groupId&gt;
               &lt;artifactId&gt;bitbucket-maven-plugin&lt;/artifactId&gt;
               &lt;version&gt;${amps.version}&lt;/version&gt;
               &lt;extensions&gt;true&lt;/extensions&gt;
               &lt;configuration&gt;
                   &lt;products&gt;
                       &lt;product&gt;
                           &lt;id&gt;bitbucket&lt;/id&gt;
                           &lt;instanceId&gt;bitbucket&lt;/instanceId&gt;
                           &lt;version&gt;${bitbucket.version}&lt;/version&gt;
                           &lt;dataVersion&gt;${bitbucket.data.version}&lt;/dataVersion&gt;
 
                           &lt;dataSources&gt;
                              &lt;dataSource&gt;
                                   &lt;jndi&gt;jdbc/OracleDataSource&lt;/jndi&gt;
                                   &lt;url&gt;jdbc:oracle:thin:@99.99.99.99:XE&lt;/url&gt;
                                   &lt;username&gt;USER&lt;/username&gt;
                                   &lt;password&gt;PASSWD&lt;/password&gt;
                                   &lt;driver&gt;oracle.jdbc.OracleDriver&lt;/driver&gt;
                                   &lt;libArtifacts&gt;
                                       &lt;libArtifact&gt;
                                           &lt;groupId&gt;com.oracle&lt;/groupId&gt;
                                           &lt;artifactId&gt;ojdbc6&lt;/artifactId&gt;
                                           &lt;version&gt;11.2.0&lt;/version&gt;
                                       &lt;/libArtifact&gt;
                                   &lt;/libArtifacts&gt;
                               &lt;/dataSource&gt;                                                                        
                           &lt;/dataSources&gt;                               
                       ...
                       &lt;/product&gt; 
             &lt;/configuration&gt;
    &lt;/plugin&gt;
   ...
&lt;build&gt;

 

Bitbucket context.xml

&lt;Context&gt;
    &lt;Resource name="jdbc/OracleDataSource"
    type="javax.sql.DataSource" 
        description="Oracle datasource for plugins"
        username="USER" password="PASWD"
        driverClassName="oracle.jdbc.OracleDriver"
        url="jdbc:oracle:thin:@99.99.99.99:1521:XE"/&gt;
&lt;/Context&gt;

 

Bitbucket server.xml

&lt;GlobalNamingResources&gt;
    &lt;Resource name="jdbc/OracleDataSource"
          type="javax.sql.DataSource" 
                  description="Oracle datasource for plugins"
                  username="SYSTEM" password="123abc"
                  driverClassName="oracle.jdbc.OracleDriver"
                  url="jdbc:oracle:thin:@192.168.0.49:1521:XE"/&gt;
&lt;/GlobalNamingResources&gt;
TAGS
AUG Leaders

Atlassian Community Events