Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- case class Database(username: String, password: String, instance: String) {
- private def getConnectString(dbStr: String): String = {
- var retval: String = null
- try {
- val p: Process = Runtime.getRuntime.exec("tnsping " + dbStr)
- val input: java.io.BufferedReader = new java.io.BufferedReader(new java.io.InputStreamReader(p.getInputStream))
- var line: String = null
- while ((({ line = input.readLine; line })) != null) {
- if (line.startsWith("Attempting to contact (")) {
- retval = line.substring(line.indexOf("("))
- }
- }
- input.close
- }
- catch {
- case ex: java.io.IOException => {
- println("IOException connecting to database: " + ex)
- }
- }
- retval
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement