3 Replies Latest reply on May 17, 2016 11:16 PM by spoorthy

    How to access the database from jive plugin?

    spoorthy Novice



      How to access the database(PostgreSQL) from jive custom plugin? could anyone give the example or steps to follow.


      Joey LeviPawan ShahRyan Rutan




        • Re: How to access the database from jive plugin?

          Is there a reason you are still writing a plugin versus writing an add-on and using the API?  (Getting Started > Building a Jive Add-On)


          Add-ons are upgrade safe and can be deployed to the cloud.

            • Re: How to access the database from jive plugin?
              Scott A Johnson Advanced

              Hi Spoorthy,


              As Joey mentioned, writing Add-ons is more upgrade safe. If you can access the info that you need through API calls, that is the preferred approach.


              But as you're probably aware, some use cases fall outside the capabilities of Add-ons.

              To write your own data access object, extend the class com.jivesoftware.base.database.dao.JiveJdbcDaoSupport


              You can then use something like this:



              private final ParameterizedRowMapper<Thing> thingMapper = new ParameterizedRowMapper<Thing>() {
                  public Thing mapRow(ResultSet rs, int num) throws SQLException {
                      final Thing thing = new Thing();
                      return thing;
              public Set<Thing> getThings(){
                  List<Thing> things = getJdbcTemplate().query("SELECT thingid, name, description FROM thing_table", thingMapper);
                  return new TreeSet<Tier>(tiers);



              Hope that helps,