Ok here’s my doubt…
I have a blazeDS (tomcat) application with some classes, each Class use the Config and DB Class for configuration and DB connection…
Here’s an example of
ConfigClass
public class Config {
public static final String DBClass = "oracle.jdbc.driver.OracleDriver";
public static final String ConnectString = "jdbc:oracle:thin:@//127.0.0.1:1521/xe";
public static final String UserDB = "user";
public static final String PasswordDB = "pass";
}
DB Class
public class DB
{
public DB() {}
public static Connection dbConnect(Connection c)
{
try
{ if (c == null || c.isClosed()){
Class.forName(Config.DBClass);
c = DriverManager.getConnection(Config.ConnectString,Config.UserDB,Config.PasswordDB);
}
return c;
}
catch (Exception e)
{
System.out.println(e.getMessage());
return null;
}
}
public static void closeConnection(Connection connection) throws SQLException
{
if (!connection.isClosed())
connection.close();
}
}
I have a test and production environment, with different user/password per DB access..
I noticed that when updating the production file with the test classes (I do not overwrite the Config.class), I got error from DB…
So, are the static final values (user/pass) in compiled version saved directly in the class itself (in my case DB.class)???
In short, yes.
An excerpt from the Java specs: