tags:

views:

108

answers:

2

So I have something like this in my boot.scala:

object DBVendor extends ConnectionManager {
 def newConnection(name: ConnectionIdentifier): Box[Connection] = {
   try {
     Class.forName("oracle.jdbc.driver.OracleDriver")
     val dm = DriverManager.getConnection("jdbc:oracle:thin:@hostname:1521:orcl", "username", "password");

     Full(dm)
   } catch {
     case e : Exception => e.printStackTrace; Empty
   }
 }
 def releaseConnection(conn: Connection) {conn.close}
}

Couple quick questions I have are... How do I set up the driver to connect?

the @hostname from what I see has been for local databases but mine is remote... I have all the information to connect to it through the sqldeveloper I use and figured that all that I would need is the hostname there.
Is the hostname all that needs to go there if thats all I needed? or will I been in need of some kind of absolute address?

A: 

As long as the machine running the code can see the hostname (which you can test with a simple ping), that's all you need.

You will need the appropriate oracle jdbc driver in the path for the Java to find. You can get the latest drivers from downloads.oracle.com

Gary
I know the connection works as I have even opened the database using the same url and username/passcode that I am using in the code. I opened it in eclipse just to make sure eclipse could connect to it. I have the oracle thin driver that I downloaded in the referenced libraries i believe from when i added it to the class path... but i get an error still that it cant find it.
What is the exact error. It's not clear whether it can't find the host or can't find the driver. If it is the host, try the IP address rather than hostname.
Gary
A: 
jalcom