System.properties
User=rootpassword=rootjdbcurl=jdbc:mysql://127.0.0.1:3306/test?useunicode=true&characterencoding=utf-8 ;d Riverclass=com.mysql.jdbc.driver
Call Method:
public void GetProperties () {Properties prop = new Properties (); try {prop.load (new Bufferedinputstream (new FileInputStream (This.getclass (). GetResource ("/"). GetPath (). substring (1) + "system.properties")); System.out.println (Prop.getproperty ("user")); System.out.println (Prop.getproperty ("password")); System.out.println (Prop.getproperty ("Jdbcurl")); System.out.println (Prop.getproperty ("Driverclass"));} catch (FileNotFoundException e) {//Todo auto-generated catch Blocke.printstacktrace ();} catch (IOException e) {//Todo Au To-generated catch Blocke.printstacktrace ();}}
Java reads the database configuration through the properties using the. properties file.