Subject | Re: Database connection |
---|---|
Author | Roman Rokytskyy |
Post date | 2004-01-16T16:59:05Z |
> I would like to set in one place the database connection variablesIn shell you just export
> like
>
> Class.forName ("org.firebirdsql.jdbc.FBDriver") ;
> java.sql.Connection connection = java.sql.DriverManager.getConnection
> ("jdbc:firebirdsql:192.168.0.115/3050:
> /home/firebird/data/database.fdb?lc_ctype=ISO8859_1","SYSDBA","passwd");
>
> so if the database or passwd change, I only have to change it at one
> place.
>
>
> Thus some one have an idea or example?
export ISC_USER=SYSDBA
export ISC_PASSWORD=masterkey
and in Java you use:
String user = System.getenv("ISC_USER");
String password = System.getenv("ISC_PASSWORD");
if (user == null || password == null)
throw new MyException("Either user name or password is not set.");
java.sql.Connection connection =
java.sql.DriverManager.getConnection(
"jdbc:firebirdsql:192.168.0.115/3050:/database.fdb",
user,
password
);
Roman