I want to write a generic function that returns both session(Cassandra database) and connection(MySQL) is it possible?
Here is my code:
def getdb: Session = {
var cluster = Cluster.builder().addContactPoint("127.0.0.1").build()
var session: Session = cluster.connect("keyspace")
if (session.getState != null) {
currentDB = "cassandra"
return session
}
else{
//code for mysql connection
return Connection
}
}
How should I define my function such that get db should return to whichever it is connected.