# DatasourceManager Java Interface

**URL:** <https://forum.inductiveautomation.com/t/datasourcemanager-java-interface/105005>\
**Category:** Ignition\
**Tags:** scripting\
**Created:** [April 11, 2025, 4:31pm UTC](https://forum.inductiveautomation.com/t/datasourcemanager-java-interface/105005 "2025-04-11T16:31:59Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![ryan.hadley](https://avatars.discourse-cdn.com/v4/letter/r/ebca7d/32.png) [@ryan.hadley](https://forum.inductiveautomation.com/u/ryan.hadley)\
**Post date:** [April 11, 2025, 4:31pm UTC](https://forum.inductiveautomation.com/t/datasourcemanager-java-interface/105005/1 "2025-04-11T16:31:59Z")

</div>

Is there a way I can access the [DatasourceManager](https://files.inductiveautomation.com/sdk/javadoc/ignition81/8.1.3/com/inductiveautomation/ignition/gateway/datasource/DatasourceManager.html#getDatasources()) interface from a script? I'd like to be able to grab a jdbc connection in a script from an established Connection in the gateway so I can perform some tasks that the standard system.db doesn't handle (specifically [Snowflake JDBC downloadStream](https://docs.snowflake.com/en/developer-guide/jdbc/jdbc-using) to access staged files). I've been able to do this manually in code with java.sql.Connection class but that means providing the entire connection string and authentication elements in my code.

Attempts to so call the interface method fail because their is no public constructor and calls to the methods are expecting 'self' argument  
INFO | jvm 1 | 2025/04/11 12:15:59 | TypeError: getDatasource(): expected 2 args; got 1

Thanks

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [April 11, 2025, 4:40pm UTC](https://forum.inductiveautomation.com/t/datasourcemanager-java-interface/105005/2 "2025-04-11T16:40:34Z")

</div>

Ignition's datasource manager is available from a gateway context, like that delivered from my [system.util.toolkitCtx()](https://www.automation-pros.com/toolkit/doc/utility.html#toolkitctx), but it isn't going to help you. Ignition runs connection pooling with a generic vanilla JDBC layer around the actual JDBC connections, plus the real connections are buried in isolated classloaders. You might succeed with java reflection. Good luck. (I've poked at that. It is fragile.)

---

<div class="post-metadata">

**Author:** ![ryan.hadley](https://avatars.discourse-cdn.com/v4/letter/r/ebca7d/32.png) [@ryan.hadley](https://forum.inductiveautomation.com/u/ryan.hadley)\
**Post date:** [April 12, 2025, 4:15pm UTC](https://forum.inductiveautomation.com/t/datasourcemanager-java-interface/105005/3 "2025-04-12T16:15:56Z")

</div>

Thank you! This was just what I needed. Believe it or not it worked . Here is a snippet

```python
context = system.util.toolkitCtx()
dbm = context.getDatasourceManager()
ds = dbm.getDatasource("DBName")
connection = ds.getConnection()
statement = connection.createStatement()
#Create Temporary Stage
statement.executeUpdate(createstage)
#Execute COPY INTO test
statement.executeUpdate(copycmd)
#Create Stream
inputstream = connection.unwrap(net.snowflake.client.jdbc.SnowflakeConnection).downloadStream(stagename,filename,False)
#Download File
system.perspective.download(filename,inputstream)

```

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [April 12, 2025, 4:38pm UTC](https://forum.inductiveautomation.com/t/datasourcemanager-java-interface/105005/4 "2025-04-12T16:38:58Z")

</div>

Well done!
