List of usage examples for java.lang Exception printStackTrace
public void printStackTrace()
From source file:Main.java
public static void main(String[] arguments) { JPanel panel = new JPanel(new BorderLayout()); JFrame frame = new JFrame(); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.add(panel);/*from w w w .j a va 2s .c o m*/ frame.setBounds(20, 20, 200, 200); frame.setVisible(true); JProgressBar progressBar = new JProgressBar(); progressBar.setIndeterminate(true); progressBar.setVisible(false); JButton loadButton = new JButton("Load memberlist"); loadButton.setEnabled(true); loadButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent arg0) { new Thread(new Runnable() { @Override public void run() { progressBar.setVisible(true); // do my stuff here... try { Thread.sleep(2000); } catch (Exception e) { e.printStackTrace(); } progressBar.setVisible(false); } }).start(); } }); JPanel container = new JPanel(new FlowLayout()); container.add(loadButton); container.add(progressBar); panel.add(container); }
From source file:FullName.java
public static void main(String[] args) { // Set up the environment for creating the initial context Hashtable<String, Object> env = new Hashtable<String, Object>(11); env.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.ldap.LdapCtxFactory"); env.put(Context.PROVIDER_URL, "ldap://localhost:389/o=JNDITutorial"); try {//from ww w .j ava 2 s .c o m // Create initial context DirContext ctx = new InitialDirContext(env); NamingEnumeration answer = ctx.search("ou=People", null); // Print the answer printSearchEnumeration(answer); // Close the context when we're done ctx.close(); } catch (Exception e) { e.printStackTrace(); } }
From source file:MainClass.java
public static void main(String[] args) { String uri = "test.xml"; try {/*from w w w.ja va 2 s .c o m*/ bookDescDOM bd = new bookDescDOM(); System.out.println("Parsing XML File: " + uri + "\n\n"); DOMParser parser = new DOMParser(); parser.setFeature("http://xml.org/sax/features/validation", true); parser.setFeature("http://xml.org/sax/features/namespaces", false); parser.parse(uri); Document doc = parser.getDocument(); bd.processNode(doc, ""); } catch (Exception e) { e.printStackTrace(); System.out.println("Error: " + e.getMessage()); } }
From source file:AuthenticationHeader.java
public static void main(String[] args) { try {//www . j a v a2 s . c o m URL marketoSoapEndPoint = new URL("CHANGE ME" + "?WSDL"); String marketoUserId = "CHANGE ME"; String marketoSecretKey = "CHANGE ME"; QName serviceName = new QName("http://www.marketo.com/mktows/", "MktMktowsApiService"); MktMktowsApiService service = new MktMktowsApiService(marketoSoapEndPoint, serviceName); MktowsPort port = service.getMktowsApiSoapPort(); // Create Signature DateFormat df = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssZ"); String text = df.format(new Date()); String requestTimestamp = text.substring(0, 22) + ":" + text.substring(22); String encryptString = requestTimestamp + marketoUserId; SecretKeySpec secretKey = new SecretKeySpec(marketoSecretKey.getBytes(), "HmacSHA1"); Mac mac = Mac.getInstance("HmacSHA1"); mac.init(secretKey); byte[] rawHmac = mac.doFinal(encryptString.getBytes()); char[] hexChars = Hex.encodeHex(rawHmac); String signature = new String(hexChars); // Set Authentication Header AuthenticationHeader header = new AuthenticationHeader(); header.setMktowsUserId(marketoUserId); header.setRequestTimestamp(requestTimestamp); header.setRequestSignature(signature); JAXBContext context = JAXBContext.newInstance(AuthenticationHeader.class); Marshaller m = context.createMarshaller(); m.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true); m.marshal(header, System.out); } catch (Exception e) { e.printStackTrace(); } }
From source file:com.microsoft.azure.shortcuts.resources.samples.AvailabilitySetSample.java
public static void main(String[] args) { try {//from w ww .j a va 2 s . c o m Subscription subscription = Subscription.authenticate("my.azureauth", null); test(subscription); } catch (Exception e) { e.printStackTrace(); } }
From source file:eu.delving.services.MockServices.java
public static void main(String... args) throws InterruptedException { try {// w w w .j a va 2 s . c o m start(); } catch (Exception e) { e.printStackTrace(); System.exit(1); } Logger.getLogger(MockServices.class).info("Waiting 10 seconds, then kill again"); Thread.sleep(10000); stop(); }
From source file:TableCellFitPagePDF.java
public static void main(String[] args) { Document document = new Document(PageSize.A4.rotate(), 50, 50, 50, 50); try {/*from www .ja v a 2s .c o m*/ PdfWriter.getInstance(document, new FileOutputStream("TableCellFitPagePDF.pdf")); document.open(); Table datatable = new Table(3); int headerwidths[] = { 10, 24, 12 }; datatable.setWidths(headerwidths); datatable.setWidth(46); datatable.setPadding(3); Cell cell = new Cell(new Phrase("title", FontFactory.getFont(FontFactory.HELVETICA, 24, Font.BOLD))); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setLeading(30); cell.setColspan(3); cell.setBorder(Rectangle.NO_BORDER); cell.setBackgroundColor(new Color(0xC0, 0xC0, 0xC0)); datatable.addCell(cell); datatable.setDefaultCellBorderWidth(2); datatable.setDefaultHorizontalAlignment(1); datatable.addCell("Header 1"); datatable.addCell("Header \n 2"); datatable.addCell("Header 3"); datatable.endHeaders(); datatable.setDefaultCellBorderWidth(1); for (int i = 0; i < 200; i++) { datatable.setDefaultHorizontalAlignment(Element.ALIGN_LEFT); datatable.addCell("1"); datatable.addCell("2"); datatable.addCell("3"); } datatable.setCellsFitPage(true); document.add(datatable); } catch (Exception e) { e.printStackTrace(); } document.close(); }
From source file:gov.va.vinci.leo.integration.IntegrationWhitespaceClient.java
public static void main(String[] args) { try {/* w w w . java 2 s. c o m*/ new IntegrationWhitespaceClient().run(); } catch (Exception e) { e.printStackTrace(); } }
From source file:InsertRowUpdatableResultSet_MySQL.java
public static void main(String[] args) { Connection conn = null;//w w w . jav a 2 s .co m Statement stmt = null; ResultSet rs = null; try { conn = getConnection(); String query = "select id, name from employees"; stmt = conn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_UPDATABLE); rs = stmt.executeQuery(query); while (rs.next()) { String id = rs.getString(1); String name = rs.getString(2); System.out.println("id=" + id + " name=" + name); } // Move cursor to the "insert row" rs.moveToInsertRow(); // Set values for the new row. rs.updateString("id", "001"); rs.updateString("name", "newName"); // Insert the new row rs.insertRow(); // scroll from the top again rs.beforeFirst(); while (rs.next()) { String id = rs.getString(1); String name = rs.getString(2); System.out.println("id=" + id + " name=" + name); } } catch (Exception e) { e.printStackTrace(); System.exit(1); } finally { // release database resources try { rs.close(); stmt.close(); conn.close(); } catch (SQLException e) { e.printStackTrace(); } } }
From source file:ReverseSelect.java
public static void main(String argv[]) { Connection con = null;//from w w w. j a v a 2s . c o 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(); } } } }