List of usage examples for java.util Properties Properties
public Properties()
From source file:ReverseSelect.java
public static void main(String argv[]) { Connection con = null;//from w w w. j a va 2 s. co m try { String url = "jdbc:msql://carthage.imaginary.com/ora"; String driver = "com.imaginary.sql.msql.MsqlDriver"; Properties p = new Properties(); Statement stmt; ResultSet rs; p.put("user", "borg"); Class.forName(driver).newInstance(); con = DriverManager.getConnection(url, "borg", ""); stmt = con.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY); rs = stmt.executeQuery("SELECT * from test ORDER BY test_id"); // as a new ResultSet, rs is currently positioned // before the first row System.out.println("Got results:"); // position rs after the last row rs.afterLast(); while (rs.previous()) { int a = rs.getInt("test_id"); String str = rs.getString("test_val"); System.out.print("\ttest_id= " + a); System.out.println("/str= '" + str + "'"); } System.out.println("Done."); } catch (Exception e) { e.printStackTrace(); } finally { if (con != null) { try { con.close(); } catch (SQLException e) { e.printStackTrace(); } } } }
From source file:JdbcConnect.java
public static void main(String[] args) throws Exception { Connection conn1 = null;//from www. ja v a2s .co m Connection conn2 = null; Connection conn3 = null; Class.forName("sun.jdbc.odbc.JdbcOdbcDriver").newInstance(); String jdbcUrl = "jdbc:odbc:authors"; String user = "yourName"; String pwd = "mypwd"; conn1 = DriverManager.getConnection(jdbcUrl); if (conn1 != null) { System.out.println("Connection 1 successful!"); } Properties prop = new Properties(); prop.put("user", user); prop.put("password", pwd); conn2 = DriverManager.getConnection(jdbcUrl, prop); if (conn2 != null) { System.out.println("Connection 2 successful!"); } conn3 = DriverManager.getConnection(jdbcUrl, user, pwd); if (conn3 != null) { System.out.println("Connection 3 successful!"); } conn1.close(); conn2.close(); conn3.close(); if (conn1.isClosed()) { System.out.println("Connection 1 is closed"); } if (conn2.isClosed()) { System.out.println("Connection 2 is closed"); } if (conn3.isClosed()) { System.out.println("Connection 3 is closed"); } conn1.close(); conn2.close(); conn3.close(); }
From source file:com.ctt.client.Client.java
public static void main(String[] args) throws Exception { Client.prop = new Properties(); FileReader reader = new FileReader("../config.properties"); Client.prop.load(reader);//from ww w . j av a 2 s . c o m String directory = Client.prop.getProperty("directory"); FilesMonitor listener = new FilesMonitor(); File folder = new File(directory); try { FileAlterationObserver observer = new FileAlterationObserver(directory); FileAlterationMonitor monitor = new FileAlterationMonitor(1000); observer.addListener(listener); monitor.addObserver(observer); monitor.start(); } catch (Exception io) { } }
From source file:com.ctt.sshlistener.Main.java
public static void main(String[] args) throws Exception { Main.prop = new Properties(); FileReader reader = new FileReader("../config.properties"); Main.prop.load(reader);//from ww w . j av a 2 s .co m String directory = Main.prop.getProperty("directory"); FilesMonitor listener = new FilesMonitor(); File folder = new File(directory); try { FileAlterationObserver observer = new FileAlterationObserver(directory); FileAlterationMonitor monitor = new FileAlterationMonitor(10000); observer.addListener(listener); monitor.addObserver(observer); monitor.start(); } catch (Exception io) { } }
From source file:core.Main.java
public static void main(String[] args) throws IOException { try {// w w w . j ava2 s . c o m for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) { /*if ("Metal".equals(info.getName())) { javax.swing.UIManager.setLookAndFeel(info.getClassName()); break; }*/ Properties props = new Properties(); props.put("logoString", "my company"); HiFiLookAndFeel.setCurrentTheme(props); // UIManager.setLookAndFeel("com.jtattoo.plaf.smart.SmartLookAndFeel"); // UIManager.setLookAndFeel("com.jtattoo.plaf.acryl.AcrylLookAndFeel"); // UIManager.setLookAndFeel("com.jtattoo.plaf.aero.AeroLookAndFeel"); UIManager.setLookAndFeel("com.jtattoo.plaf.aluminium.AluminiumLookAndFeel"); // UIManager.setLookAndFeel("com.jtattoo.plaf.bernstein.BernsteinLookAndFeel"); // UIManager.setLookAndFeel("com.jtattoo.plaf.fast.FastLookAndFeel"); // UIManager.setLookAndFeel("com.jtattoo.plaf.graphite.GraphiteLookAndFeel"); // UIManager.setLookAndFeel("com.jtattoo.plaf.hifi.HiFiLookAndFeel"); // UIManager.setLookAndFeel("com.jtattoo.plaf.luna.LunaLookAndFeel"); // UIManager.setLookAndFeel("com.jtattoo.plaf.mcwin.McWinLookAndFeel"); // UIManager.setLookAndFeel("com.jtattoo.plaf.mint.MintLookAndFeel"); // UIManager.setLookAndFeel("com.jtattoo.plaf.noire.NoireLookAndFeel"); } } catch (ClassNotFoundException | InstantiationException | IllegalAccessException | javax.swing.UnsupportedLookAndFeelException ex) { } MainFrame frame = new MainFrame(); frame.setVisible(true); frame.setResizable(false); }
From source file:batch.processing.usage.chunk.hibernate.BatchChunkHibernateProcessingUsage.java
/** * @param args the command line arguments *//* www. j a va2 s . co m*/ public static void main(String[] args) { try { Properties jobParameters = new Properties(); jobParameters.put("nomeArquivo", "OpLm.csv"); BatchProcess launcher = BatchApplication.createExecutionProcess("chunkHibernateExample", jobParameters); BatchExecution execution = launcher.start(); while (execution.getStatus() != Status.COMPLETED) { try { Thread.sleep(500); } catch (InterruptedException ex) { } } System.out.println(execution.toString()); } catch (Exception ex) { LOG.error(ex); } }
From source file:com.googlecode.dex2jar.bin_gen.BinGen.java
/** * @param args//from www .j a va2s. co m * @throws IOException */ public static void main(String[] args) throws IOException { Properties p = new Properties(); p.load(BinGen.class.getResourceAsStream("class.cfg")); String bat = FileUtils.readFileToString( new File("src/main/resources/com/googlecode/dex2jar/bin_gen/bat_template"), "UTF-8"); String sh = FileUtils.readFileToString( new File("src/main/resources/com/googlecode/dex2jar/bin_gen/sh_template"), "UTF-8"); File binDir = new File("src/main/bin"); String setclasspath = FileUtils.readFileToString( new File("src/main/resources/com/googlecode/dex2jar/bin_gen/setclasspath.bat"), "UTF-8"); FileUtils.writeStringToFile(new File(binDir, "setclasspath.bat"), setclasspath, "UTF-8"); for (Object key : p.keySet()) { String name = key.toString(); FileUtils.writeStringToFile(new File(binDir, key.toString() + ".sh"), sh.replaceAll("__@class_name@__", p.getProperty(name)), "UTF-8"); FileUtils.writeStringToFile(new File(binDir, key.toString() + ".bat"), bat.replaceAll("__@class_name@__", p.getProperty(name)), "UTF-8"); } }
From source file:ConnectionPoolBasics.java
public static void main(String args[]) throws Exception { GenericObjectPool gPool = new GenericObjectPool(); /*Class.forName("com.mysql.jdbc.Driver"); //from w ww . j a va 2s . co m DriverManagerConnectionFactory cf = new DriverManagerConnectionFactory( "jdbc:mysql://localhost/commons", "root", "");*/ Properties props = new Properties(); props.setProperty("Username", "root"); props.setProperty("Password", ""); ConnectionFactory cf = new DriverConnectionFactory(new com.mysql.jdbc.Driver(), "jdbc:mysql://localhost/commons", props); KeyedObjectPoolFactory kopf = new GenericKeyedObjectPoolFactory(null, 8); PoolableConnectionFactory pcf = new PoolableConnectionFactory(cf, gPool, kopf, null, false, true); for (int i = 0; i < 5; i++) { gPool.addObject(); } // PoolingDataSource pds = new PoolingDataSource(gPool); PoolingDriver pd = new PoolingDriver(); pd.registerPool("example", gPool); for (int i = 0; i < 5; i++) { gPool.addObject(); } Connection conn = java.sql.DriverManager.getConnection("jdbc:apache:commons:dbcp:example"); System.err.println("Connection: " + conn); //": Delegate: " + ((org.apache.commons.dbcp.PoolingConnection)conn).getDelegate()); // do some work with the connection PreparedStatement ps = conn.prepareStatement("Select * from customer where id = ?"); System.err.println("Active: " + gPool.getNumActive() + ", Idle: " + gPool.getNumIdle()); conn.close(); System.err.println("Active: " + gPool.getNumActive() + ", Idle: " + gPool.getNumIdle()); }
From source file:net.tirasa.olingooauth2.Main.java
public static void main(final String[] args) throws Exception { final Properties oauth2Properties = new Properties(); oauth2Properties.load(Main.class.getResourceAsStream("/oauth2.properties")); final AzureADOAuth2HttpClientFactory oauth2HCF = new AzureADOAuth2HttpClientFactory( oauth2Properties.getProperty("oauth2.authority"), oauth2Properties.getProperty("oauth2.clientId"), oauth2Properties.getProperty("oauth2.redirectURI"), oauth2Properties.getProperty("oauth2.resourceURI"), new UsernamePasswordCredentials(oauth2Properties.getProperty("oauth2.username"), oauth2Properties.getProperty("oauth2.password"))); final ODataClient client = ODataClientFactory.getEdmEnabledV4("https://outlook.office365.com/ews/odata"); client.getConfiguration().setHttpClientFactory(oauth2HCF); final ODataEntitySetRequest<ODataEntitySet> messages = client.getRetrieveRequestFactory() .getEntitySetRequest(/* w w w . j a v a 2 s .c o m*/ URI.create("https://outlook.office365.com/ews/odata/Me/Folders('Inbox')/Messages")); for (ODataEntity message : messages.execute().getBody().getEntities()) { System.out.println("Message: " + message.getId()); } }
From source file:com.idega.util.FileLocalizer.java
public static void main(String[] args) { if (args.length != 2) { System.err.println("Wimp. I need two parameters, input file og directory and output file"); System.err.println("Usage java FileLocalizer input output"); return;// ww w . j av a 2 s .c om } File in = null; BufferedWriter out = null; Properties props = new Properties(); try { in = new File(args[0]); } catch (Exception e) { System.err.println("Auli. Error : " + e.toString()); return; } try { out = new BufferedWriter(new FileWriter(args[1])); } catch (java.io.IOException e) { System.err.println("Auli. Error : " + e.toString()); return; } try { findRecursive(in, props); props.list(new PrintWriter(out)); } catch (Exception e) { System.err.println("Error reading or writing file : " + e.toString()); } try { out.close(); } catch (java.io.IOException e) { System.err.println("Error closing files : " + e.toString()); } }