Shua42
Databricks Employee
Databricks Employee

Hey there @I-am-Biplab ,

I'm a bit confused on the ask here. I'm assuming your code isn't running on a databricks cluster, in which case you can use the JDBC url of a running SQL warehouse to write data directly to a Databricks table. See the example code below:

        Properties connectionProperties = new Properties();
        connectionProperties.setProperty("user", "token");
        connectionProperties.setProperty("password", "<DATABRICKS_PERSONAL_ACCESS_TOKEN>");

        String jdbcUrl = "jdbc:databricks://<workspace-hostname>:443/default;transportMode=http;ssl=1;httpPath=<sql-warehouse-http-path>";

        // Write to Databricks table
        df.write()
                .mode("append") // or "overwrite"
                .jdbc(jdbcUrl, "your_table_name", connectionProperties);

If you are running on a Databricks cluster, you should be able to write directly to a table with:

Dataset<Row> df = spark.read()
    .format("parquet") // or "csv", "json", etc., depending on your data format
    .load("s3a://your-bucket/path/to/data");

df.write()
    .format("delta")
    .mode("append") // or "overwrite" as per your requirement
    .saveAsTable("your_catalog.your_schema.your_table");

 Let me know if I'm understanding your ask correctly.