It's not the same without you
Join the community to find out what other Atlassian users are discussing, debating and creating.
Hi,
My goal is simple: within a Confluence servlet plugin, create a SQL connection to different database than Confluence uses and retrieve / store some data. Should be easy but after weeks it has become very frustrating and we're on the verge of dropping Confluence integration at all and just build a dedicated web application.
We took the following approaches:
Context ctx = new InitialContext();
DataSource ds = (DataSource) ctx.lookup("java:comp/env/jdbc/DocControlDB");
Connection conn = ds.getConnection();
Statement stmt = conn.createStatement();
ResultSet rs = stmt.executeQuery("SELECT * FROM DATABASE.dbo.TABLE");
etcetcetc
Quite some topics can be found covering the ClassNotFoundException related to IntialContext. The one that seemed to work was listed here:
ClassLoader origCL = Thread.currentThread().getContextClassLoader();
try {
Thread.currentThread().setContextClassLoader(ComponentManager.class.getClassLoader());
//::TODO:: do lookup here
} finally {
Thread.currentThread().setContextClassLoader(origCL);
}
The ComponentManager does not exist anymore. I tried with ContainerManager but doesn't work either.
I found quite some reference material using google, but most of the comments are of the 2012-2014 era, and solutions posted there do not work anymore.
If somebody could create a simple example on how to include SQL connectivity, preferrably using JNDI, that would be awesome :-)
This community is celebrating its one-year anniversary and Atlassian co-founder Mike Cannon-Brookes has all the feels.
Read moreHi Community! Kesha (kay-sha) from the Confluence marketing team here! Can you share stories with us on how your non-technical (think Marketing, Sales, HR, legal, etc.) teams are using Confluen...
Connect with like-minded Atlassian users at free events near you!
Find a groupConnect with like-minded Atlassian users at free events near you!
Unfortunately there are no AUG chapters near you at the moment.
Start an AUGYou're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.