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 to NetSuite SuiteAnalytics Using Token-Based-Authentication (TBA)

ashap551
New Contributor II

I'm trying to connect to NetSuite2.com using Pyspark from a Databricks Notebook utilizing a JDBC driver.

I was successful in setting up my DBVisualizer connection by installing the JDBC Driver (JAR) and generating the password with the one-time hashing NONCE as required.

However, when I tried to run the same URL, JAR, and Password (utilizing NONCE) in pyspark (within Databricks)--- I came up with the following error:

 

SparkException: Job aborted due to stage failure: Task 0 in stage 36.0 failed 4 times, most recent failure: Lost task 0.3 in stage 36.0 (TID ***) (*** executor 1): java.sql.SQLException: [NetSuite][SuiteAnalytics Connect JDBC Driver][OpenAccess SDK SQL Engine]Failed to login using TBA. Error ticket# m3z*********cp2f[232]

 

I followed the password regeneration rules the same I did for DBVisualizer, but this still did not work. I tried multiple combinations in CustomProperties and keep getting this error.

Please look at the following code and identify the error and how to correct it:

 

pwd = generate_tba_password(account_id, consumer_key, token_id, consumer_secret, token_secret)

# Construct the JDBC URL
jdbc_url = f"jdbc:ns://{host}:{port};ServerDataSource=NetSuite2.com;Encrypted=1;NegotiateSSLClose=false;" \
f"CustomProperties=(AccountID={account_id};RoleID={role_id};AuthType=TOKEN;" \
f"TokenID={token_id};TokenSecret={token_secret};ConsumerKey={consumer_key};ConsumerSecret={consumer_secret})"

# Read data from NetSuite
df = spark.read.format("jdbc") \
.option("url", jdbc_url) \
.option("User", "TBA") \
.option("Password", pwd) \
.option("driver", "com.netsuite.jdbc.openaccess.OpenAccessDriver") \
.option("dbtable", "customer") \
.load()

df.show()

 

 

2 REPLIES 2

alicerichard65
New Contributor

It seems like the issue might be related to the password generation or the JDBC URL configuration. Here are a few things you can check: NextCareurgentcare

1. Password Generation: Ensure that the generate_tba_password function is correctly implemented and returns a valid password

2. JDBC URL: Make sure the JDBC URL is correctly formatted and does not contain any unnecessary parameters
Remove the ciphersuites parameter if it's present, as the JDBC server automatically selects the appropriate cipher suite

3. CustomProperties: Double-check the CustomProperties in the JDBC URL to ensure they are correctly set.

Here's a revised version of your code with some adjustments:

pwd = generate_tba_password(account_id, consumer_key, token_id, consumer_secret, token_secret)

# Construct the JDBC URL
jdbc_url = f"jdbc:ns://{host}:{port};ServerDataSource=NetSuite2.com;Encrypted=1;NegotiateSSLClose=false;" \
f"CustomProperties=(AccountID={account_id};RoleID={role_id};AuthType=TOKEN;" \
f"TokenID={token_id};TokenSecret={token_secret};ConsumerKey={consumer_key};ConsumerSecret={consumer_secret})"

# Read data from NetSuite
df = spark.read.format("jdbc") \
.option("url", jdbc_url) \
.option("User", "TBA") \
.option("Password", pwd) \
.option("driver", "com.netsuite.jdbc.openaccess.OpenAccessDriver") \
.option("dbtable", "customer") \
.load()

df.show()

 

Thank you.  Now I did confirm all my code works via DBVisualizer.  So the connection string and password generator appears correct.

I do have a question though.  I looked at the revised code and found it identical to my code.  Where you expecting to put a refinement that perhaps was lost?

thanks again for your help!

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