# Performance issue for 3rd party module

**URL:** <https://forum.inductiveautomation.com/t/performance-issue-for-3rd-party-module/7916>\
**Category:** 3rd Party Modules\
**Created:** [January 28, 2014, 4:11pm UTC](https://forum.inductiveautomation.com/t/performance-issue-for-3rd-party-module/7916 "2014-01-28T16:11:18Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![mreddy](https://avatars.discourse-cdn.com/v4/letter/m/b19c9b/32.png) [@mreddy](https://forum.inductiveautomation.com/u/mreddy)\
**Post date:** [January 28, 2014, 4:11pm UTC](https://forum.inductiveautomation.com/t/performance-issue-for-3rd-party-module/7916/1 "2014-01-28T16:11:18Z")

</div>

Friends,

I have created module using jar file and xml file. the jar file contains java methods which gets and manipulate data using db connection. when i run the methods in ignition from module it taking lot time(nearly 20-25 seconds) to execute the result. please help me in this scenario.

mreddy,  
OpteBiz Pvt Ltd.

---

<div class="post-metadata">

**Author:** ![Kyle\_Chase](https://avatars.discourse-cdn.com/v4/letter/k/9de0a6/32.png) [@Kyle\_Chase](https://forum.inductiveautomation.com/u/Kyle_Chase)\
**Post date:** [January 29, 2014, 6:00pm UTC](https://forum.inductiveautomation.com/t/performance-issue-for-3rd-party-module/7916/2 "2014-01-29T18:00:40Z")

</div>

First, take all of your code and run it through a source code reverser. This will make all your logic operate in reverse. Then configure your code to output its debug routines into a VFD. The VFD should finally put your data into a text file, and from there your code will run really, really fast.

But in all seriousness, how do you expect us to help you with this post. If your code is taking a long time to run, its probably the logic inside your module. Post some code, let us know what the expected performance is, what are you comparing this to to determine that the module made your code slow, etc. Basic troubleshooting skills and the ability to formulate a proper request for help will go a long way.

---

<div class="post-metadata">

**Author:** ![nmudge](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/nmudge/32/3394_2.png) [@nmudge](https://forum.inductiveautomation.com/u/nmudge)\
**Post date:** [January 29, 2014, 7:03pm UTC](https://forum.inductiveautomation.com/t/performance-issue-for-3rd-party-module/7916/3 "2014-01-29T19:03:50Z")

</div>

Had me going for a second… Good advice.

---

<div class="post-metadata">

**Author:** ![JordanCClark](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/jordancclark/32/83362_2.png) [@JordanCClark](https://forum.inductiveautomation.com/u/JordanCClark)\
**Post date:** [January 30, 2014, 10:42am UTC](https://forum.inductiveautomation.com/t/performance-issue-for-3rd-party-module/7916/4 "2014-01-30T10:42:23Z")

</div>

I was going to recommend a [turbo encabulator](http://www.youtube.com/watch?v=61R2P20Ca2U)…

---

<div class="post-metadata">

**Author:** ![mreddy](https://avatars.discourse-cdn.com/v4/letter/m/b19c9b/32.png) [@mreddy](https://forum.inductiveautomation.com/u/mreddy)\
**Post date:** [February 13, 2014, 7:08am UTC](https://forum.inductiveautomation.com/t/performance-issue-for-3rd-party-module/7916/5 "2014-02-13T07:08:57Z")

</div>

Here I am pasting some code using for db connection in java.

[code]@SuppressWarnings({“CallToThreadDumpStack”, “null”, “ConstantConditions”, “UnusedAssignment”})  
public static void getBonecpDBConnectionForInsert(String strQuery){

```
    // Define required variables.
    BoneCP connectionPool = null;
    BoneCPConfig config = null;
    Connection connection = null;
    Statement stmt = null;
    
    // Check for JDBC Driver class.
    try {
        // load the database driver (make sure this is in your classpath!)
        Class.forName("com.mysql.jdbc.Driver");
    } 
    catch (Exception e) {
        e.printStackTrace();
    }

    try {
        // Setup the connection pool.
        config = new BoneCPConfig();
        config.setJdbcUrl(strJdbcUrl); // jdbc url specific to your database, eg jdbc:mysql://127.0.0.1/yourdb
        config.setUsername(strUserName);
        config.setPassword(strPassword);
        config.setMinConnectionsPerPartition(5);
        config.setMaxConnectionsPerPartition(10);
        config.setPartitionCount(1);
        connectionPool = new BoneCP(config); // setup the connection pool
        connection = connectionPool.getConnection(); // fetch a connection
       
        if (connection != null){
            stmt = connection.createStatement();
            stmt.executeUpdate(strQuery); // use the query to update the data]
        }
        connectionPool.shutdown(); // shutdown connection pool.
    } catch (SQLException e) {
        e.printStackTrace();
    } finally {
       connectionPool.shutdown();
        config = null;
        stmt = null;
         if (connection != null) {
            try {
                connection.close();
            } catch (SQLException e) {
               e.printStackTrace();
            }
        }
    }
   
}[/code]
```

---

<div class="post-metadata">

**Author:** ![Kyle\_Chase](https://avatars.discourse-cdn.com/v4/letter/k/9de0a6/32.png) [@Kyle\_Chase](https://forum.inductiveautomation.com/u/Kyle_Chase)\
**Post date:** [February 15, 2014, 11:12pm UTC](https://forum.inductiveautomation.com/t/performance-issue-for-3rd-party-module/7916/6 "2014-02-15T23:12:44Z")

</div>

Is there a reason why you are trying to roll your own connection pool, as opposed to using the one Ignition has built in, which is accessible via context.getDatasourceManager?

---

<div class="post-metadata">

**Author:** ![Kyle\_Chase](https://avatars.discourse-cdn.com/v4/letter/k/9de0a6/32.png) [@Kyle\_Chase](https://forum.inductiveautomation.com/u/Kyle_Chase)\
**Post date:** [February 15, 2014, 11:19pm UTC](https://forum.inductiveautomation.com/t/performance-issue-for-3rd-party-module/7916/7 "2014-02-15T23:19:45Z")

</div>

Also, create connections in this manner is very expensive. Even rolling your own persistence connection pool would be better. However, using the one built into Ignition would be best.
