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
Databricks Employee
Databricks Employee

@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!

Connect with Databricks Users in Your Area

Join a Regional User Group to connect with local Databricks users. Events will be happening in your city, and you won’t want to miss the chance to attend and share knowledge.

If there isn’t a group near you, start one and help create a community that brings people together.

Request a New Group