If the configuration file is Dblink.properties, under the Conf folder in the root directory of the project,
The contents of the configuration file are as follows:
JDBCURL=JDBC:ORCALE:THIN:@172.16.5.22:1521:XXDB (database name) user=xxxx (user name) password=xxxx (password)
The configuration file is then read in your database connection class and can be read before loading the driver.
As follows:
Static { inputstream in = dblinkdao.class.getclassloader (). getResourceAsStream ("/conf/dblink.properties"); (in this line of code, Dblinkdao is to control the scope of the search configuration file, and if the following path is an absolute path, the class can be any Java class ,. Class.getclassloader () is to get a class loader) Properties properties = new Properties (); try{ properties.load (in); (Loading parts) } catch (IOEXCEPTION E1) { E1.printstacktrace (); } conn_str = properties.getproperty (" Jdbcurl "); db_user = properties.getproperty (" USER "); Db_pwd = properties.getpropErty ("password"); (Load driver code) }
After that, the normal database connection operation
Read the database configuration method from the configuration file in eclipse