Example usage for java.util Properties setProperty

List of usage examples for java.util Properties setProperty

Introduction

In this page you can find the example usage for java.util Properties setProperty.

Prototype

public synchronized Object setProperty(String key, String value) 

Source Link

Document

Calls the Hashtable method put .

Usage

From source file:Main.java

public static void main(String[] args) throws Exception {
    Properties properties = new Properties();
    properties.setProperty("database.type", "mysql");
    properties.setProperty("database.url", "jdbc:mysql://localhost/mydb");
    properties.setProperty("database.username", "root");
    properties.setProperty("database.password", "root");

    FileOutputStream fos = new FileOutputStream("database-configuration.xml");
    properties.storeToXML(fos, "Database Configuration", "UTF-8");
}

From source file:Main.java

public static void main(String[] args) throws Exception {
    Properties prop = new Properties();

    prop.setProperty("Chapter Count", "200");
    prop.put("Tutorial Count", "1500");
    prop.put("tutorial", "java2s.com");

    // print the list
    System.out.println(prop);//from  www .  j  a  v  a2  s. c o m

    // store the properties list in an output stream
    prop.store(System.out, "Main");

}

From source file:Main.java

public static void main(String[] args) throws Exception {
    Properties prop = new Properties();

    prop.setProperty("Chapter Count", "200");
    prop.put("Tutorial Count", "1500");
    prop.put("tutorial", "java2s.com");

    // print the list
    System.out.println(prop);//  w ww.j ava  2s.  co m

    // change the properties
    prop.setProperty("Tutorial Count", "15");
    prop.setProperty("Chapter Count", "500");

    // print the list
    System.out.println(prop);
}

From source file:Main.java

public static void main(String[] args) throws Exception {
      Properties properties = new Properties();
      properties.setProperty("database.type", "mysql");
      properties.setProperty("database.url", "jdbc:mysql://localhost/mydb");
      properties.setProperty("database.username", "root");
      properties.setProperty("database.password", "root");

      FileOutputStream fos = new FileOutputStream("database-configuration.xml");
      properties.storeToXML(fos, "Database Configuration", "UTF-8");
  }/*from  w w w . j a v a  2  s . c  o m*/

From source file:Main.java

public static void main(String[] args) {
    Properties properties = new Properties();

    properties.setProperty("name", "Designer");
    properties.setProperty("version", "1.0");
    properties.setProperty("vendor", "Inc");

    Map<String, String> map = new HashMap<String, String>((Map) properties);

    Set propertySet = map.entrySet();
    for (Object o : propertySet) {
        Map.Entry entry = (Map.Entry) o;
        System.out.printf("%s = %s%n", entry.getKey(), entry.getValue());
    }//w  w w  .  j av a2  s  .  c o  m
}

From source file:Main.java

public static void main(String args[]) {

    Properties prop = new Properties();

    prop.setProperty("A", "t@h.com");
    prop.setProperty("B", "k@h.com");
    prop.setProperty("C", "R@h.com");
    prop.setProperty("D", "S@h.com");

    HashMap<String, String> propMap = new HashMap<String, String>((Map) prop);

    Set<Map.Entry<String, String>> propSet;
    propSet = propMap.entrySet();//from  ww w. jav  a2 s  .co  m

    System.out.println("Contents of map: ");
    for (Map.Entry<String, String> me : propSet) {
        System.out.print(me.getKey() + ": ");
        System.out.println(me.getValue());
    }
}

From source file:TestDataEncryptionIntegrity.java

public static void main(String[] argv) throws Exception {

    DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver());

    Properties prop = new Properties();
    prop.setProperty("user", "scott");
    prop.setProperty("password", "tiger");
    prop.setProperty("oracle.net.encryption_client", "REQUIRED");
    prop.setProperty("oracle.net.encryption_types_client", "( RC4_40 )");
    prop.setProperty("oracle.net.crypto_checksum_client", "REQUIRED");
    prop.setProperty("oracle.net.crypto_checksum_types_client", "( MD5 )");

    Connection conn = DriverManager.getConnection("jdbc:oracle:thin:@dssw2k01:1521:orcl", prop);
    Statement stmt = conn.createStatement();
    ResultSet rset = stmt.executeQuery(
            "select 'Hello Thin driver Encryption & Integrity " + "tester '||USER||'!' result from dual");
    while (rset.next())
        System.out.println(rset.getString(1));
    rset.close();/*from  w  w w .  j  a  v  a  2s  . c o m*/
    stmt.close();
    conn.close();
}

From source file:TestDSBind.java

public static void main(String args[]) throws SQLException, NamingException {

    // For this to work you will need to create the
    // directories /JNDI/JDBC on your file system first
    Context ctx = null;/*  ww w  .j  av  a2 s. c o m*/
    try {
        Properties prop = new Properties();
        prop.setProperty(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.fscontext.RefFSContextFactory");
        prop.setProperty(Context.PROVIDER_URL, "file:/JNDI/JDBC");
        ctx = new InitialContext(prop);
    } catch (NamingException ne) {
        System.err.println(ne.getMessage());
    }

    OracleDataSource ds = new OracleDataSource();
    ds.setDriverType("thin");
    ds.setServerName("dssw2k01");
    ds.setPortNumber(1521);
    ds.setDatabaseName("orcl");
    ds.setUser("scott");
    ds.setPassword("tiger");

    ctx.bind("joe", ds);
}

From source file:TestSSL.java

public static void main(String[] argv) throws Exception {

    DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver());

    Properties prop = new Properties();
    prop.setProperty("user", "scott");
    prop.setProperty("password", "tiger");
    // THIS DOES NOT WORK YET
    prop.setProperty("oracle.net.ssl_cipher_suites",
            "(ssl_rsa_export_with_rc4_40_md5, ssl_rsa_export_with_des40_cbc_sha)");
    prop.setProperty("oracle.net.ssl_client_authentication", "false");
    prop.setProperty("oracle.net.ssl_version", "3.0");
    prop.setProperty("oracle.net.encryption_client", "REJECTED");
    prop.setProperty("oracle.net.crypto_checksum_client", "REJECTED");
    Connection conn = DriverManager.getConnection(
            "jdbc:oracle:thin:@(DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCPS)(HOST = dssw2k01)(PORT = 2484))) (CONNECT_DATA = (SERVICE_NAME = DSSW2K01)))",
            prop);/*from   w w w  . j a  v  a2  s .  c o m*/
    Statement stmt = conn.createStatement();
    ResultSet rset = stmt
            .executeQuery("select 'Hello Thin driver SSL " + "tester '||USER||'!' result from dual");
    while (rset.next())
        System.out.println(rset.getString(1));
    rset.close();
    stmt.close();
    conn.close();
}

From source file:com.jkoolcloud.client.samples.query.QueryData1.java

public static void main(String[] args) {
    try {//from ww w . j a va  2s.  c o  m
        Properties props = new Properties();
        props.setProperty(JKCmdOptions.PROP_URI, JKQuery.JKOOL_QUERY_URL);
        JKCmdOptions options = new JKCmdOptions(QueryData1.class, args, props);
        if (options.usage != null) {
            System.out.println(options.usage);
            System.exit(-1);
        }
        options.print();
        JKQuery jkQuery = new JKQuery(options.token);
        HttpResponse response = jkQuery.get(options.query);
        System.out.println(EntityUtils.toString(response.getEntity()));
    } catch (Exception e) {
        e.printStackTrace();
    }
}