List of usage examples for java.lang Exception printStackTrace
public void printStackTrace()
From source file:Main.java
public static void main(String args[]) { try {// w w w. ja v a 2s . co m DefaultBoundedRangeModel model = new DefaultBoundedRangeModel(); ChangeListener myListener = new MyChangeListener(); model.addChangeListener(myListener); System.out.println(model.toString()); System.out.println("Now setting minimum to 50 . . ."); model.setMinimum(50); System.out.println(model.toString()); System.out.println("Now setting maximum to 40 . . ."); model.setMaximum(40); System.out.println(model.toString()); System.out.println("Now setting maximum to 50 . . ."); model.setMaximum(50); System.out.println(model.toString()); System.out.println("Now setting extent to 30 . . ."); model.setExtent(30); System.out.println(model.toString()); System.out.println(model.getExtent()); System.out.println("Now setting several properties . . ."); if (!model.getValueIsAdjusting()) { model.setValueIsAdjusting(true); System.out.println(model.toString()); model.setMinimum(0); model.setMaximum(100); model.setExtent(20); model.setValueIsAdjusting(false); } System.out.println(model.toString()); } catch (Exception e) { e.printStackTrace(); } }
From source file:Main.java
public static void main(String args[]) { try {//from w ww. j a va 2 s . c om DefaultBoundedRangeModel model = new DefaultBoundedRangeModel(); ChangeListener myListener = new MyChangeListener(); model.addChangeListener(myListener); System.out.println(model.toString()); System.out.println("Now setting minimum to 50 . . ."); model.setMinimum(50); System.out.println(model.toString()); System.out.println("Now setting maximum to 40 . . ."); model.setMaximum(40); System.out.println(model.toString()); System.out.println("Now setting maximum to 50 . . ."); model.setMaximum(50); System.out.println(model.toString()); System.out.println("Now setting extent to 30 . . ."); model.setExtent(30); System.out.println(model.toString()); System.out.println(model.getValue()); System.out.println("Now setting several properties . . ."); if (!model.getValueIsAdjusting()) { model.setValueIsAdjusting(true); System.out.println(model.toString()); model.setMinimum(0); model.setMaximum(100); model.setExtent(20); model.setValueIsAdjusting(false); } System.out.println(model.toString()); } catch (Exception e) { e.printStackTrace(); } }
From source file:Main.java
public static void main(String[] argv) { JEditorPane jep = new JEditorPane(); jep.setContentType("text/html"); StringBuilder sb = new StringBuilder(); sb.append("<b>Welcome</b>:<br><hr>"); for (int i = 1; i <= 3; i++) { sb.append(create(i));//from www . j a v a 2s . co m } sb.append("<hr>"); jep.setText(sb.toString()); jep.setEditable(false); jep.addHyperlinkListener(e -> { if (HyperlinkEvent.EventType.ACTIVATED.equals(e.getEventType())) { System.out.println(e.getURL()); Desktop desktop = Desktop.getDesktop(); try { desktop.browse(e.getURL().toURI()); } catch (Exception ex) { ex.printStackTrace(); } } }); JFrame f = new JFrame(); f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); f.add(jep); f.pack(); f.setVisible(true); }
From source file:TableCellAlignmentCenterMiddlePDF.java
public static void main(String[] args) { Document document = new Document(PageSize.A4, 50, 50, 50, 50); try {//w w w. j a va2 s. c o m PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream("TableCellAlignmentCenterMiddlePDF.pdf")); document.open(); PdfPTable table = new PdfPTable(2); table.setWidthPercentage(100); table.getDefaultCell().setBorder(Rectangle.NO_BORDER); table.getDefaultCell().setHorizontalAlignment(Element.ALIGN_CENTER); table.getDefaultCell().setVerticalAlignment(Element.ALIGN_MIDDLE); table.getDefaultCell().setFixedHeight(70); table.addCell("!"); table.addCell("Text Text Text Text Text Text "); table.addCell(new Phrase(new Chunk("cell"))); table.addCell("Text Text "); table.addCell(new Phrase(new Chunk("cell"))); table.addCell("Text Text Text "); table.addCell(new Phrase(new Chunk("cell"))); table.addCell("Text \nText \nText "); table.addCell(new Phrase(new Chunk("cell"))); table.addCell("Text "); table.addCell(new Phrase(new Chunk("cell"))); table.addCell("Text "); table.addCell(new Phrase(new Chunk("cell"))); table.addCell("Text "); table.addCell(new Phrase(new Chunk("cell"))); document.add(table); } catch (Exception de) { de.printStackTrace(); } document.close(); }
From source file:com.usefullc.solm.common.proxy.nio.NIOSocketServer.java
public static void main(String[] args) { try {/* www . j ava2 s .c om*/ //proxy connect pool System.setProperty("htmlDir", args[0]); int port = Integer.valueOf(args[1]); ServerMgr.init(port); //end System.out.println("htmlDir=" + args[0]); System.out.println("port=" + args[1]); ProxyTaskExecutor.start(); //? new Thread(new Runnable() { @Override public void run() { ServerMgr.startServer(); // ReadHandler.start(); //?browser req and server res ? } }).start(); System.out.println("server is start at " + ServerMgr.getPort()); } catch (Exception e) { e.printStackTrace(); } }
From source file:SqlException.java
public static void main(String[] args) { Connection conn = null;/*from w w w.ja v a2 s.c o m*/ Statement stmt = null; ResultSet rs = null; try { String driver = "oracle.jdbc.driver.OracleDriver"; Class.forName(driver).newInstance(); System.out.println("Connecting to database..."); String jdbcUrl = "jdbc:oracle:thin:@localhost:1521:ORCL"; conn = DriverManager.getConnection(jdbcUrl, "yourName", "mypwd"); stmt = conn.createStatement(); try { rs = stmt.executeQuery("Select * from no_table_exisits"); } catch (SQLException seRs) { String exMsg = "Message from MySQL Database"; String exSqlState = "Exception"; SQLException mySqlEx = new SQLException(exMsg, exSqlState); seRs.setNextException(mySqlEx); throw seRs; } } catch (SQLException se) { int count = 1; while (se != null) { System.out.println("SQLException " + count); System.out.println("Code: " + se.getErrorCode()); System.out.println("SqlState: " + se.getSQLState()); System.out.println("Error Message: " + se.getMessage()); se = se.getNextException(); count++; } } catch (Exception e) { e.printStackTrace(); } }
From source file:DemoDataTruncation.java
public static void main(String[] args) throws Exception { Connection conn = getMySQLConnection(); Statement stmt = null;// w w w . j a v a 2 s . c o m try { stmt = conn.createStatement(); stmt.executeUpdate("DELETE FROM animals_table"); displayError(stmt.getWarnings()); stmt.executeUpdate( "INSERT INTO animals_table(id, name)" + "VALUES(1, 'NameLongerThanColumnLengthInDatabase')"); displayError(stmt.getWarnings()); } catch (DataTruncation dt) { displayError(dt); dt.printStackTrace(); } catch (SQLException se) { System.out.println("Database error message: " + se.getMessage()); } catch (Exception e) { e.printStackTrace(); } finally { stmt.close(); conn.close(); } }
From source file:GetDateFromMySql.java
public static void main(String args[]) { ResultSet rs = null;/* w w w .j a v a2 s . co m*/ Connection conn = null; Statement stmt = null; try { conn = getMySQLConnection(); stmt = conn.createStatement(); rs = stmt.executeQuery("select timeCol, dateCol, dateTimeCol from dateTimeTable"); while (rs.next()) { java.sql.Time dbSqlTime = rs.getTime(1); java.sql.Date dbSqlDate = rs.getDate(2); java.sql.Timestamp dbSqlTimestamp = rs.getTimestamp(3); System.out.println("dbSqlTime=" + dbSqlTime); System.out.println("dbSqlDate=" + dbSqlDate); System.out.println("dbSqlTimestamp=" + dbSqlTimestamp); java.util.Date dbSqlTimeConverted = new java.util.Date(dbSqlTime.getTime()); java.util.Date dbSqlDateConverted = new java.util.Date(dbSqlDate.getTime()); System.out.println("in standard date"); System.out.println(dbSqlTimeConverted); System.out.println(dbSqlDateConverted); } } catch (Exception e) { e.printStackTrace(); } finally { try { rs.close(); stmt.close(); conn.close(); } catch (SQLException e) { e.printStackTrace(); } } }
From source file:Update.java
public static void main(String args[]) { Connection con = null;/*from w w w . j av a 2 s .c o m*/ if (args.length != 2) { System.out.println("Syntax: <java UpdateApp [number] [string]>"); return; } try { String driver = "com.imaginary.sql.msql.MsqlDriver"; Class.forName(driver).newInstance(); String url = "jdbc:msql://carthage.imaginary.com/ora"; con = DriverManager.getConnection(url, "borg", ""); Statement s = con.createStatement(); String test_id = args[0]; String test_val = args[1]; int update_count = s.executeUpdate( "INSERT INTO test (test_id, test_val) " + "VALUES(" + test_id + ", '" + test_val + "')"); System.out.println(update_count + " rows inserted."); s.close(); } catch (Exception e) { e.printStackTrace(); } finally { if (con != null) { try { con.close(); } catch (SQLException e) { e.printStackTrace(); } } } }
From source file:CreateTableWithAllDataTypesInMySQL.java
public static void main(String[] args) throws Exception { PreparedStatement pstmt = null; Connection conn = null;/*w w w .java 2 s . co m*/ try { StringBuffer sql = new StringBuffer("CREATE TABLE tableWithAllTypes("); sql.append("column_boolean BOOL, "); // boolean sql.append("column_byte TINYINT, "); // byte sql.append("column_short SMALLINT, "); // short sql.append("column_int INTEGER, "); // int sql.append("column_long BIGINT, "); // long sql.append("column_float FLOAT, "); // float sql.append("column_double DOUBLE PRECISION, "); // double sql.append("column_bigdecimal DECIMAL(13,0), "); // BigDecimal sql.append("column_string VARCHAR(254), "); // String sql.append("column_date DATE, "); // Date sql.append("column_time TIME, "); // Time sql.append("column_timestamp TIMESTAMP, "); // Timestamp sql.append("column_asciistream1 TINYTEXT, "); // Clob ( 2^8 bytes) sql.append("column_asciistream2 TEXT, "); // Clob ( 2^16 bytes) sql.append("column_asciistream3 MEDIUMTEXT, "); // Clob (2^24 bytes) sql.append("column_asciistream4 LONGTEXT, "); // Clob ( 2^32 bytes) sql.append("column_blob1 TINYBLOB, "); // Blob ( 2^8 bytes) sql.append("column_blob2 BLOB, "); // Blob ( 2^16 bytes) sql.append("column_blob3 MEDIUMBLOB, "); // Blob ( 2^24 bytes) sql.append("column_blob4 LONGBLOB)"); // Blob ( 2^32 bytes) conn = getConnection(); pstmt = conn.prepareStatement(sql.toString()); pstmt.executeUpdate(); } catch (Exception e) { e.printStackTrace(); } finally { conn.close(); } }