Skip to content

Instantly share code, notes, and snippets.

@niroj-office
Last active November 7, 2020 04:27
Show Gist options
  • Save niroj-office/80af00d7eb18be3f510b0c5b0ec242dd to your computer and use it in GitHub Desktop.
Save niroj-office/80af00d7eb18be3f510b0c5b0ec242dd to your computer and use it in GitHub Desktop.
try {
properties.load(this.getClass().getClassLoader().getResourceAsStream(configFilePath.resolveEnv)) )
catch {
case e: Exception = throw new FileNotFoundException(s"$ConfigFilePath configFilePath is absent !!")
}
var queries = query
val connection_type = properties.getProperty("connection type", "<invalid connections>").resolveEnv
val url = properties.getProperty("url", "<invalid_url>").resolveEnv
val driver = properties.getProperty("driver", "<invalid url>").resolveEnv
val user = properties.getProperty("user", "<invalid user>").resolveEnv
val password = properties.getProperty("password", "<invalid passwd").resolveEnv
var batchsize = properties.getProperty("batchsize", s"$commitNbr").resolveEnv
val brConnect = if (spark.isDefined) spark.get.sparkContext.broadcast(properties) else null
try {
queries = if (query matches "^\\s*file\\s*:.*")
fromFile(query.replaceAll("\\s*file\\s*:\\s*", ""))
.getLines.mkString(";")
else
query
} catch{
case e: Exception logger.error(s"\nError reading the SQL file $(query}")
e.printStackTrace()
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment