cancel
Showing results for 
Search instead for 
Did you mean: 
Data Engineering
Join discussions on data engineering best practices, architectures, and optimization strategies within the Databricks Community. Exchange insights and solutions with fellow data engineers.
cancel
Showing results for 
Search instead for 
Did you mean: 

JDBC connection

Joao_DE
New Contributor III

Hi everyone!

I have a question. For a project I need to establish a jdbc connection using spark.read. My question is when does the connection is deleted. That is because I will read multiple tables from that database, so if I could just create a connection and then reuse, it would be better.

If this does not work, is the method dbutils.notebook.exit() able to clean memory on the JVM used and in consequence delete the connection?

4 REPLIES 4

shan_chandra
Esteemed Contributor
Esteemed Contributor

@João Peixoto​  - Please use %scala System.gc() to explicitly release the free memory from JVM. Please note: JVM process won't explicitly releases memory back as it is an expensive process to request memory again.

Joao_DE
New Contributor III

Hi Shan!

First, thank you for your help. I cannot use scala, because the cluster used is a shared cluster. Can I do the same using python?

Anonymous
Not applicable

Hi @João Peixoto​ 

Hope all is well! Just wanted to check in if you were able to resolve your issue and would you be happy to share the solution or mark an answer as best? Else please let us know if you need more help. 

We'd love to hear from you.

Thanks!

Joao_DE
New Contributor III

Hi Vidula!

I haven´t figure out a solution yet, so any help would be appreciated

Thank you!

Join 100K+ Data Experts: Register Now & Grow with Us!

Excited to expand your horizons with us? Click here to Register and begin your journey to success!

Already a member? Login and join your local regional user group! If there isn’t one near you, fill out this form and we’ll create one for you to join!