Read the code for the SRC document of the Java project in eclipse

Source: Internet
Author: User

The project catalogue is as follows:

=====================================================

Config.properties file code is as follows:

#jdbc Connect Database parameters
#connect Oracle Parameters
Driver=oracle.jdbc.driver.oracledriver
Url=jdbc:oracle:thin: @localhost: 1521:ORCL
Username=scott
Password=tiger

======================================================

Test.java source files are as follows:

Package Dean;

Import java.io.IOException;
Import Java.io.InputStream;
Import java.util.Properties;


public class Test {
Private Properties prop = null;
Public Properties getProperties () {
Prop = new Properties ();
InputStream FIS = This.getclass (). getClassLoader (). getResourceAsStream ("config.properties");
try {
Prop.load (FIS);
catch (IOException E1) {
TODO auto-generated Catch block
E1.printstacktrace ();
}finally{
try {
Fis.close ();
catch (IOException e) {
TODO auto-generated Catch block
E.printstacktrace ();
}
}
return prop;
}
public static void Main (string[] args) {
Test T = new Test ();
Properties prop = T.getproperties ();
String Driver = prop.getproperty ("Driver");
String url = prop.getproperty ("url");
String username = prop.getproperty ("username");
String Password = prop.getproperty ("password");
SYSTEM.OUT.PRINTLN (driver);
System.out.println (URL);
SYSTEM.OUT.PRINTLN (username);
SYSTEM.OUT.PRINTLN (password);
}
}

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.