Access data through JDBC/SQL

Hi All,
I have to query multiple sql queries, and in some case one 2nd sql query is dependent on the results from first query (results returned are used in the where clause). What should be my approach?

  1. Should i save my first query results in a tempview and loop it around to get access to the 2nd results, create the sql, execute it. And follow the same with next row data from tempview.
  2. I have created a runquery function , but do i need to every time also mention connection details. (like driver, url, user, password… etc). How can i make a common connection function.
  3. I am using df.select(“xyz”).collect()(0) to access the first row+column result. What are the other ways to access the rows and loop through them.
    Can any one help with a sample code piece.
    Thanks in Advance
    Sunny

Depends strongly on which SQL library you are using (the Scala ecosystem has many), what your transaction requirements are, and maybe which SQL DB you’re using. Details matter for stuff like this, and many of those details have more to do with the database than with Scala per se…

Hi Justin,
I am using DB2.