Hi All,
Below is the code which is used to run the query from Oracle Database and load them to CSV files using Scala.
object Main { def main(args: Array[String]): Unit = { /* Local connection details*/ val dbUser = "dbusernameo" val dbPassword = "dbpassword" val dbURL = "jdbc:oracle:thin:@11.2.4.80:1234:databasename" val configQuery = """ SELECT
First_Name,Last_Name,Middle_Name,Student_Number ,Grade_Level,Enroll_Status,Gender from Students Where rownum<2 """ val conConfig =
OracleConnect.connJdbc(dbUser, dbPassword, dbURL) val statement =
conConfig.createStatement() statement.setFetchSize(1000) val resultSet: java.sql.ResultSet =
statement.executeQuery(configQuery) /* Read all the variable from Orcale
table*/ while (resultSet.next) { // var oracleURL =
resultSet.getString("First_Name") // var oracleUser =
resultSet.getString("Last_Name") //var oraclePassword =
resultSet.getString("Middle_Name") //var oracleOutPutFilePath =
resultSet.getString("Student_Number") //var oracleOutPutFileDateFormat =
resultSet.getString("Student_Number") // var oracleQueryFilePath =
resultSet.getString("Grade_Level") //val Enroll_Status =
resultSet.getString("Enroll_Status") //val Gender =
resultSet.getString("Gender") oracleURL = "jdbc:oracle:thin:@11.2.4.80:1234:databasename
"
oracleUser = " dbusernameo " oraclePassword = "dbpassword" oracleOutPutFilePath = "C:\\Scala\\student.csv" oracleOutPutFileDateFormat = "yyyyMMdd" oracleQueryFilePath = "C:\\Scala\\Config\\sampleQuery.txt" /* Call CSV export function*/ CSVExport.exportCSVFile(oracleUser,
oraclePassword, oracleURL, oracleOutPutFilePath, oracleOutPutFileDateFormat,
oracleQueryFilePath) } } } |
your valuable information and time. Please keep updating.
ReplyDeleteMsbi Developer Course
Best Msbi Online Training
Thank you for sharing wonderful information with us to get some idea about that content.
ReplyDeleteMsbi Online Course
Msbi Online Training