List of usage examples for java.lang Exception printStackTrace
public void printStackTrace()
From source file:SetDefaultCellLeadingPDF.java
public static void main(String[] args) { Document document = new Document(PageSize.A4.rotate(), 10, 10, 10, 10); try {//from w w w . ja v a 2 s . c om PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream("SetDefaultCellLeadingPDF.pdf")); document.open(); PdfPTable table = new PdfPTable(2); PdfPCell cell; Paragraph p = new Paragraph( "Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text "); table.addCell("cell"); table.addCell(p); table.addCell("cell"); cell = new PdfPCell(p); table.getDefaultCell().setLeading(0f, 1.0f); table.addCell(cell); table.addCell("cell"); document.add(table); } catch (Exception de) { de.printStackTrace(); } document.close(); }
From source file:SimpleConnection.java
static public void main(String args[]) { Connection connection = null; if (args.length != 4) { System.out.println("Syntax: java SimpleConnection " + "DRIVER URL UID PASSWORD"); return;//from w ww . j av a 2 s . c om } try { Class.forName(args[0]).newInstance(); } catch (Exception e) { e.printStackTrace(); return; } try { connection = DriverManager.getConnection(args[1], args[2], args[3]); System.out.println("Connection successful!"); } catch (SQLException e) { e.printStackTrace(); } finally { if (connection != null) { try { connection.close(); } catch (SQLException e) { e.printStackTrace(); } } } }
From source file:com.weib.soundsystem.CDPlayerMain.java
public static void main(String[] args) { AnnotationConfigApplicationContext context = null; try {/*from ww w. jav a 2s . c o m*/ context = new AnnotationConfigApplicationContext(CDPlayerConfig.class); // SgtPeppers sp = (SgtPeppers) context.getBean("sgtPeppers"); // sp.play(); // CDPlayer cdplayer = context.getBean(CDPlayer.class); // cdplayer.play(); WhiteAlbum cd = context.getBean(WhiteAlbum.class); CDPlayer cdplayer = context.getBean(CDPlayer.class, cd); cdplayer.play(); // CDPlayer cdwriter = (CDPlayer) context.getBean("cdWriter", (WhiteAlbum)context.getBean("whiteAlbum")); // cdwriter.play(); } catch (Exception e) { e.printStackTrace(); } finally { if (context != null) { context.close(); } } }
From source file:com.sender.request.SenderUtil.java
public static void main(String[] args) { try {// w w w . j ava 2 s. co m post(); } catch (Exception e) { e.printStackTrace(); } }
From source file:com.everm.propertydescriptor.App.java
/** * @param args//from w w w . java 2 s . co m */ public static void main(String[] args) { try { Object bean = new App(); PropertyDescriptor[] pds = PropertyUtils.getPropertyDescriptors(bean); Class beanClass = bean.getClass(); for (int i = 0; i < pds.length; i++) { String key = pds[i].getName(); Class type = pds[i].getPropertyType(); if (pds[i].getReadMethod() != null) { Object value = PropertyUtils.getProperty(bean, key); } else { String warning = "Property '" + key + "' has no read method. SKIPPED"; } } } catch (Exception e) { e.printStackTrace(); } }
From source file:LockingCellWidthsPDF.java
public static void main(String[] args) { Document document = new Document(PageSize.A4, 36, 36, 36, 36); try {//from www . j a va 2 s . co m PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream("LockingCellWidthsPDF.pdf")); document.open(); float[] widths = { 0.1f, 0.1f, 0.05f, 0.75f }; PdfPTable table = new PdfPTable(widths); table.addCell("10%"); table.addCell("10%"); table.addCell("5%"); table.addCell("75%"); table.addCell("111111111111111111111111111"); table.addCell("111111111111111"); table.addCell("11111"); table.addCell("11"); table.setTotalWidth(300); table.setLockedWidth(true); document.add(table); } catch (Exception de) { de.printStackTrace(); } document.close(); }
From source file:Main.java
public static void main(String[] args) { char[] arr = { 'H', 'e', 'l', 'l', 'o' }; try {/*from ww w. jav a2 s . c om*/ OutputStream os = new FileOutputStream("test.txt"); OutputStreamWriter writer = new OutputStreamWriter(os); // create a new FileInputStream to read what we write FileInputStream in = new FileInputStream("test.txt"); // write something in the file writer.write(arr, 0, 3); // flush the stream writer.flush(); // read what we write for (int i = 0; i < 3; i++) { System.out.print((char) in.read()); } writer.close(); in.close(); } catch (Exception ex) { ex.printStackTrace(); } }
From source file:CreateDatabase.java
public static void main(String[] args) { Connection connection = null; Statement statement = null;//ww w . j a v a2s .c o m try { Class.forName("org.gjt.mm.mysql.Driver").newInstance(); String url = "jdbc:mysql://localhost/mysql"; connection = DriverManager.getConnection(url, "username", "password"); statement = connection.createStatement(); String hrappSQL = "CREATE DATABASE hrapp"; statement.executeUpdate(hrappSQL); } catch (Exception e) { e.printStackTrace(); } finally { if (statement != null) { try { statement.close(); } catch (SQLException e) { } // nothing we can do } if (connection != null) { try { connection.close(); } catch (SQLException e) { } // nothing we can do } } }
From source file:SimpleAnnotationsDrawRectangleToShowAnnotation.java
public static void main(String[] args) { Document document1 = new Document(PageSize.A4, 10, 10, 10, 10); try {/*from w w w .ja va 2 s . c o m*/ PdfWriter writer1 = PdfWriter.getInstance(document1, new FileOutputStream("SimpleAnnotationsDrawRectangleToShowAnnotation.pdf")); writer1.setPdfVersion(PdfWriter.VERSION_1_5); document1.open(); Annotation a = new Annotation("authors", "Text for an annotation", 250f, 250f, 350f, 350f); document1.add(a); // draw rectangles to show where the annotations were added PdfContentByte cb1 = writer1.getDirectContent(); cb1.rectangle(250, 700, 100, 100); cb1.rectangle(250, 550, 100, 100); cb1.rectangle(250, 400, 100, 100); cb1.rectangle(250, 250, 100, 100); cb1.stroke(); } catch (Exception de) { de.printStackTrace(); } document1.close(); }
From source file:Main.java
public static void main(String[] args) throws Exception { Connection conn = null;/*from w w w . j ava 2s . c o m*/ PreparedStatement pstmt = null; try { conn = getConnection(); String query = "insert into message values(?, ?, ?)"; pstmt = conn.prepareStatement(query); // create a statement pstmt.setInt(1, 5); // set input parameter 1 pstmt.setString(2, "head5"); // set input parameter 2 pstmt.setString(3, "data5"); // set input parameter 3 pstmt.executeUpdate(); // execute insert statement pstmt = conn.prepareStatement("insert into msgtag values(?, ?, ?)"); // create a statement pstmt.setInt(1, 55); // set input parameter 1 pstmt.setString(2, "tag5"); // set input parameter 2 pstmt.setInt(3, 5); // set input parameter 3 pstmt.executeUpdate(); // execute insert statement } catch (Exception e) { e.printStackTrace(); } finally { pstmt.close(); conn.close(); } }