cancel
Showing results for 
Search instead for 
Did you mean: 
Warehousing & Analytics
Engage in discussions on data warehousing, analytics, and BI solutions within the Databricks Community. Share insights, tips, and best practices for leveraging data for informed decision-making.
cancel
Showing results for 
Search instead for 
Did you mean: 

What is the difference between :443/default and Database=default in JDBC connection string

charlie_cai
New Contributor II

When I use following java code to get namespace from AWD Databricks:

 

 

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.Statement;
import java.util.Properties;

public class DatabricksJDBCExample {
    public static void main(String[] args) {
        String jdbcUrl = "jdbc:spark://your-databricks-workspace-url:443/default;transportMode=http;ssl=true;httpPath=sql/protocolv1/o/your-org-id/your-workspace-id";
        String accessToken = "token";

        try {
            // Load the JDBC driver class
            Class.forName("com.databricks.driver.Driver");
			
			Properties connectionProperties = new Properties();

            // Set the necessary properties for the connection
            connectionProperties.setProperty("user", "token");
            connectionProperties.setProperty("PWD", accessToken);

            // Create a connection using the JDBC URL and access token
            Connection conn = DriverManager.getConnection(jdbcUrl, connectionProperties);


            // Create a statement
            Statement stmt = conn.createStatement();

            // Get the list of namespaces (databases)
            String showNamespacesQuery = "SHOW NAMESPACES";
            ResultSet namespacesResult = stmt.executeQuery(showNamespacesQuery);

            System.out.println("Namespaces (Databases):");
            while (namespacesResult.next()) {
                String namespace = namespacesResult.getString(1);
                System.out.println(namespace);
            }

            namespacesResult.close();
            stmt.close();
            conn.close();
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}

 

 

I can get 'default' as result.

After I changed the connection string to database=default

String jdbcUrl = "jdbc:spark://your-databricks-workspace-url:443;transportMode=http;ssl=true;httpPath=sql/protocolv1/o/your-org-id/your-workspace-id;database=default";

 It will throw error:

[SparkJDBCDriver](500051) ERROR processing query/statement. Error Code: 0, SQL state: TStatus(statusCode:ERROR_STATUS, infoMessages:[*org.apache.hive.service.cli.HiveSQLException:Configuration database is not available.:48:47

1 REPLY 1

Tharun-Kumar
Databricks Employee
Databricks Employee

@charlie_cai 

database is not a valid configuration parameter available in the jdbc string. You can use ConnCatalog and ConnSchema to provide this information.

This is also documented here - https://docs.databricks.com/en/integrations/jdbc-odbc-bi.html#:~:text=To%20specify%20the%20default%2....

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