List of usage examples for java.util Properties Properties
public Properties()
From source file:MainClass.java
public static void main(String[] args) throws Exception { Properties props = new Properties(); String host = "yourHost.edu"; String username = "userName"; String password = "mypassword"; String provider = "pop3"; Session session = Session.getDefaultInstance(props, null); Store store = session.getStore(provider); store.connect(host, username, password); Folder inbox = store.getFolder("INBOX"); if (inbox == null) { System.out.println("No INBOX"); System.exit(1);/* w w w . j a va 2 s.c o m*/ } inbox.open(Folder.READ_ONLY); Message[] messages = inbox.getMessages(); for (int i = 0; i < messages.length; i++) { System.out.println("Message " + (i + 1)); messages[i].writeTo(System.out); } inbox.close(false); store.close(); }
From source file:MainClass.java
public static void main(String args[]) { String name = "Test print job"; Properties properties = new Properties(); PrintJob pj = Toolkit.getDefaultToolkit().getPrintJob(new MainClass(), name, properties); if (pj != null) { printDimensions(pj.getGraphics(), pj.getPageDimension()); pj.end();//from w w w . j ava2 s. com } }
From source file:Main.java
public static void main(String[] args) throws Exception { Class.forName("com.mysql.jdbc.Driver"); Connection conn = null;/* w w w .j a v a 2s . com*/ Properties info = new Properties(); // info.put("proxy_type", "4"); // SSL Tunneling info.put("proxy_host", "[proxy host]"); info.put("proxy_port", "[proxy port]"); info.put("proxy_user", "[proxy user]"); info.put("proxy_password", "[proxy password]"); info.put("user", "[db user]"); info.put("password", "[db pass word]"); conn = DriverManager.getConnection("jdbc:mysql://[db host]/", info); Statement stmt = conn.createStatement(); ResultSet rs = stmt.executeQuery("Select NOW()"); rs.next(); System.out.println("Data- " + rs.getString(1)); rs.close(); stmt.close(); conn.close(); }
From source file:Main.java
public static void main(String[] args) throws Exception { Properties props = new Properties(); props.put("mail.host", "mail.cloud9.net"); Session mailConnection = Session.getInstance(props, null); Message msg = new MimeMessage(mailConnection); Address a = new InternetAddress("a@a.com", "A a"); Address b = new InternetAddress("fake@java2s.com"); msg.setContent("Mail contect", "text/plain"); msg.setFrom(a);// w ww . j a v a 2 s. c o m msg.setRecipient(Message.RecipientType.TO, b); msg.setSubject("subject"); Transport.send(msg); }
From source file:Main.java
public static void main(String[] args) throws Exception { Properties props = new Properties(); String host = "yourserver.edu"; String provider = "pop3"; Session session = Session.getDefaultInstance(props, new MailAuthenticator()); Store store = session.getStore(provider); store.connect(host, null, null);//from ww w. j a va 2 s. c om Folder inbox = store.getFolder("INBOX"); if (inbox == null) { System.out.println("No INBOX"); System.exit(1); } inbox.open(Folder.READ_ONLY); Message[] messages = inbox.getMessages(); for (int i = 0; i < messages.length; i++) { System.out.println("Message " + (i + 1)); messages[i].writeTo(System.out); } inbox.close(false); store.close(); }
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 .ja v a2s. c o m*/ stmt.close(); conn.close(); }
From source file:Main.java
public static void main(String[] args) throws Exception { Class.forName("org.gjt.mm.mysql.Driver"); Properties info = new Properties(); Driver driver = DriverManager.getDriver("jdbc:mysql://localhost/demo2s"); System.out.println("driver=" + driver); DriverPropertyInfo[] attributes = driver.getPropertyInfo("jdbc:mysql://localhost/demo2s", info); System.out.println("attributes=" + attributes); // zero length means a connection attempt can be made System.out.println("Resolving properties for: " + driver.getClass().getName()); for (int i = 0; i < attributes.length; i++) { // get the property metadata String name = attributes[i].name; String[] choices = attributes[i].choices; boolean required = attributes[i].required; String description = attributes[i].description; // printout property metadata System.out.println(name + " (Required: " + required + ")"); if (choices == null) { System.out.println(" No choices."); } else {/*from w w w .j av a2 s . c o m*/ System.out.print(" Choices are: "); for (int j = 0; j < choices.length; j++) { System.out.print(" " + choices[j]); } } System.out.println(" Description: " + description); } }
From source file:Main.java
public static void main(String[] args) throws Exception { URLName server = new URLName("protocol://username:password@host/foldername"); Session session = Session.getDefaultInstance(new Properties(), null); Folder folder = session.getFolder(server); if (folder == null) { System.out.println("Folder " + server.getFile() + " not found."); System.exit(1);//from w ww . j a v a2s. co m } folder.open(Folder.READ_ONLY); // Get the messages from the server Message[] messages = folder.getMessages(); for (int i = 0; i < messages.length; i++) { System.out.println("------------ Message " + (i + 1) + " ------------"); messages[i].writeTo(System.out); } folder.close(false); }
From source file:Main.java
public static void main(String[] args) { Properties properties = new Properties(); String dataFolder = properties.getProperty("data.folder"); System.out.println("dataFolder = " + dataFolder); String jdbcUrl = properties.getProperty("jdbc.url"); System.out.println("jdbcUrl = " + jdbcUrl); }
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);/* ww w . j a va 2s. com*/ 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(); }