Using IDE Database Connections in Java code [message #668366] |
Mon, 19 February 2018 16:21 |
|
CMcKinstry
Messages: 3 Registered: February 2018
|
Junior Member |
|
|
I can find plenty of examples of how to create Database Connections in JDeveloper.
What I cannot find is how to make use of any connections in actual code.
Is it even possible?
E.g. I've created a connection called testConnection and I want to use it.
This certainly doesn't work:
Connection conn = DriverManager.getConnection(testConnection);
My basic underlying problem is I need to run a Java app once a day that communicates with a bunch of databases (Oracle and other types). This app is to be automated and run from Windows. I really do not to expose passwords for this, and these Database Connections looked like a clever way of getting around this problem. I potentially need to run it from several Window Servers.
If it is possible, how do I access these Database Connections?
Thanks,
|
|
|
|
|
|
Re: Using IDE Database Connections in Java code [message #668386 is a reply to message #668369] |
Tue, 20 February 2018 12:47 |
|
CMcKinstry
Messages: 3 Registered: February 2018
|
Junior Member |
|
|
Thanks, that doesn't use the named database connection (testConnection). I'd still have to use the JDBC string along with username and password.
E.g.:
Note:
The login variables have been set to null to secure the application. At this point in the guide, application login functionality is yet to be built into the application. Therefore, to test the application until login functionality is built in, you can set values in the login variables as follows:
Set the jdbcUrl variable to the connect string for your database.
String jdbcUrl = "jdbc:oracle:thin:@localhost:1521:ORCL";
Set the variables userid and password to hr as follows:
String userid = "hr";
String password = "hr";
Make sure you reset these to null as soon as you finish testing.
For more information on security features and practices, refer to Oracle Database Security Guide and the vendor-specific documentation for your development environment.
What I'd like to do is use the Database Connection (i.e. testConnection). I'm trying to do this as a way of not making the password visible - I'm trying to write an application that is run automatically once a day. I cannot put in my batch file (that will call the Java app) the password, nor do I want to store the password within a Java class or file where it could be gotten at.
I've looked at hashing (e.g. SHA-512), which as far I can tell, worthless for connecting to a database (the password will be successfully hashed, but I cannot then use it to establish a connection, since the hashed password cannot be "un-hashed".
Thanks,
I'm open to ideas where an automated job (called once a day) can successfully have the password passed "un-exposed" in Windows.
|
|
|
|
|