Example usage for java.lang Exception printStackTrace

List of usage examples for java.lang Exception printStackTrace

Introduction

In this page you can find the example usage for java.lang Exception printStackTrace.

Prototype

public void printStackTrace() 

Source Link

Document

Prints this throwable and its backtrace to the standard error stream.

Usage

From source file:GetDateFromOracle.java

public static void main(String args[]) {
    String GET_RECORD = "select date_column, time_column, " + "timestamp_column from TestDates where id = ?";
    ResultSet rs = null;/*from   ww w  . jav  a2  s .c  om*/
    Connection conn = null;
    PreparedStatement pstmt = null;
    try {
        conn = getConnection();
        pstmt = conn.prepareStatement(GET_RECORD);
        pstmt.setString(1, "0001");
        rs = pstmt.executeQuery();
        while (rs.next()) {
            java.sql.Date dbSqlDate = rs.getDate(1);
            java.sql.Time dbSqlTime = rs.getTime(2);
            java.sql.Timestamp dbSqlTimestamp = rs.getTimestamp(3);
            System.out.println("dbSqlDate=" + dbSqlDate);
            System.out.println("dbSqlTime=" + dbSqlTime);
            System.out.println("dbSqlTimestamp=" + dbSqlTimestamp);
        }
    } catch (Exception e) {
        e.printStackTrace();
    } finally {
        try {
            rs.close();
            pstmt.close();
            conn.close();
        } catch (SQLException e) {
            e.printStackTrace();
        }
    }
}

From source file:Technique.PostFile.java

public static void main(String[] args) {
    try {// w  w  w .  j a va  2s  . c  om
        PostFile.upload("C:\\Users\\FATHLLAH Wael\\Pictures\\bird-text-funny-wallpaper-1920x1200.jpg");
    } catch (Exception e) {

        e.printStackTrace();
    }
}

From source file:com.project.finalproject.Send.java

public static void main(String[] argv) throws Exception {
    ConnectionFactory factory = new ConnectionFactory();
    factory.setHost("localhost");
    Connection connection = factory.newConnection();
    Channel channel = connection.createChannel();
    channel.queueDeclare(QUEUE_NAME, false, false, false, null);

    try {/* w ww . j  a  va2  s.  c o  m*/
        InputStream is = new FileInputStream("hr.json");
        String jsontxt = IOUtils.toString(is);
        JSONObject jsonObject = new JSONObject(jsontxt);
        JSONArray stream = jsonObject.getJSONArray("stream");
        for (int i = 0; i < stream.length(); i++) {
            String message = stream.getJSONObject(i).getString("value");
            channel.basicPublish("", QUEUE_NAME, null, message.getBytes("UTF-8"));
            System.out.println(" [x] Sent '" + message + "'");
            TimeUnit.SECONDS.sleep(1);
        }
    } catch (FileNotFoundException fe) {
        fe.printStackTrace();
    } catch (Exception e) {
        e.printStackTrace();
    }

    channel.close();
    connection.close();
}

From source file:NestedTablesPDF.java

public static void main(String[] args) {
    Document document = new Document(PageSize.A4.rotate(), 10, 10, 10, 10);
    try {/*from   w w  w . j av a2 s.  c o  m*/
        PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream("NestedTablesPDF.pdf"));
        document.open();
        PdfPTable table = new PdfPTable(4);
        PdfPTable nested1 = new PdfPTable(2);
        nested1.addCell("1.1");
        nested1.addCell("1.2");

        PdfPTable nested2 = new PdfPTable(1);
        nested2.addCell("2.1");
        nested2.addCell("2.2");

        table.addCell(nested1);
        table.addCell("cell ");
        table.addCell("cell ");
        table.addCell("cell ");
        table.addCell("cell ");
        table.addCell("cell ");

        table.addCell(nested2);
        table.addCell("cell ");
        table.addCell("cell ");
        table.addCell("cell ");
        table.addCell("cell ");
        document.add(table);
        document.close();
    } catch (Exception de) {
        de.printStackTrace();
    }
    document.close();
}

From source file:Main.java

public static void main(String[] args) {
    Connection conn = null;//from  www . ja v  a 2  s . co  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:de.meldanor.melchatclient.Core.java

public static void main(String[] args) {
    System.out.println("Starting client...");
    String[] connInfo = parseArguments(args);
    NetworkHandler nHandler = null;/*from  ww w.  j av a 2 s. c  o  m*/
    try {
        nHandler = new NetworkHandler(connInfo[0], connInfo[1]);
    } catch (Exception e) {
        e.printStackTrace();
        return;
    }
    System.out.println("Client started!");
    nHandler.clientLoop();

}

From source file:de.tudarmstadt.ukp.experiments.argumentation.comments.pipeline.DebateStatistics.java

public static void main(String[] args) {
    String inFolder = args[0];//  w  w  w.j ava  2 s.c om
    try {
        SimplePipeline.runPipeline(
                CollectionReaderFactory.createReaderDescription(DebateArgumentReader.class,
                        DebateArgumentReader.PARAM_SOURCE_LOCATION, inFolder),
                // statistics
                AnalysisEngineFactory.createEngineDescription(DebateStatistics.class));
    } catch (Exception ex) {
        ex.printStackTrace();
    }
}

From source file:Main.java

public static void main(String[] args) throws Exception {
    String url = "jdbc:odbc:databaseName";
    String driver = "sun.jdbc.odbc.JdbcOdbcDriver";
    String user = "guest";
    String password = "guest";

    try {/* w ww  .j a v a 2s  .  c o m*/
        Class.forName(driver);
        Connection conn = DriverManager.getConnection(url, user, password);

        // Get the MetaData
        DatabaseMetaData metaData = conn.getMetaData();

        // Get driver information
        System.out.println("Driver Informaion");
        System.out.println(metaData.getDriverName());
        System.out.println(metaData.getDriverVersion());
        // Get schema information
        System.out.println("Schemas");
        ResultSet schemas = metaData.getSchemas();
        while (schemas.next()) {
            System.out.println(schemas.getString(1));
        }
        // Get table information
        System.out.println("Tables");
        ResultSet tables = metaData.getTables("", "", "", null);
        while (tables.next()) {
            System.out.println(tables.getString(3));
        }
        conn.close();
    } catch (Exception ex) {
        ex.printStackTrace();
    }
}

From source file:com.fileanalyzer.main.Main.java

public static void main(String[] args) throws IOException {
    FileAnalyzer fl = null;//from w ww  .ja  va  2s  . co m
    try {
        ClassPathXmlApplicationContext ctx = new ClassPathXmlApplicationContext("spring.xml");
        Configuration conf = (Configuration) ctx.getBean("configuration");
        fl = (FileAnalyzer) ctx.getBean("fileAnalyzer");
        if (args.length == 3 && args[1].equalsIgnoreCase("s")) {
            log.info("Added file id: " + fl.analizeString(args[0], args[2]));
        } else if (args.length == 2 && args[1].equalsIgnoreCase("a")) {
            fl.analizeFile(args[0], true);
        } else if (args.length == 1)
            fl.analizeFile(args[0], false);
        else {
            log.info(conf.getWrongParams());
            Thread.sleep(3000);
            System.exit(1);
        }
        log.info("Press any key to exit...");
        System.in.read();
    } catch (Exception ex) {
        ex.printStackTrace();
    } finally {
        if (fl != null) {
            fl.shutDown();
        }
        System.exit(0);
    }
}

From source file:edu.cornell.med.icb.goby.modes.GobyDriver.java

public static void main(final String[] args) throws IOException, JSAPException {
    final String version = VersionUtils.getImplementationVersion(GobyDriver.class);
    DynamicOptionRegistry.autoRegister();
    if (LOG.isDebugEnabled()) {
        LOG.debug(GobyDriver.class.getName() + " Implementation-Version: " + version);
        LOG.debug("Running with: " + ArrayUtils.toString(args));
    }//from ww  w.j  a  v a 2s  .c om
    int status = 0;
    try {
        new GobyDriver().configure(args).execute();
    } catch (Exception e) {
        e.printStackTrace();
        status = 1;
    }
    System.exit(status);
}