Example usage for java.lang Exception getMessage

List of usage examples for java.lang Exception getMessage

Introduction

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

Prototype

public String getMessage() 

Source Link

Document

Returns the detail message string of this throwable.

Usage

From source file:TestAccessExcel.java

public static void main(String args[]) {
    Connection conn = null;/* ww w  .  j  a v  a  2s .c o  m*/
    Statement stmt = null;
    ResultSet rs = null;
    try {
        conn = getConnection();
        stmt = conn.createStatement();
        String excelQuery = "select * from [Sheet1$]";
        rs = stmt.executeQuery(excelQuery);

        while (rs.next()) {
            System.out.println(rs.getString("BadgeNumber") + " " + rs.getString("FirstName") + " "
                    + rs.getString("LastName"));
        }
    } catch (Exception e) {
        System.err.println(e.getMessage());
    } finally {
        try {
            rs.close();
            stmt.close();
            conn.close();

        } catch (SQLException e) {
            e.printStackTrace();
        }
    }
}

From source file:org.silverpeas.migration.contentmanagement.DuplicateContentRemovingApplication.java

public static void main(String[] args) {
    try {/*from w  w  w. ja v a 2  s  .  c o m*/
        init();
        DuplicateContentRemoving migration = new DuplicateContentRemoving();
        migration.setConsole(console);
        migration.setConnection(ConnectionFactory.getConnection());
        migration.migrate();
    } catch (Exception ex) {
        console.printError(ex.getMessage(), ex);
    } finally {
        console.close();
    }
}

From source file:TableCellSpanPDF.java

public static void main(String[] args) {
    Document document = new Document();

    try {/*  w  ww  .j a  v a 2s .  co m*/
        PdfWriter.getInstance(document, new FileOutputStream("TableCellSpanPDF.pdf"));
        document.open();

        PdfPTable table = new PdfPTable(3);
        PdfPCell cell = new PdfPCell(new Paragraph("header with colspan 3"));
        cell.setColspan(3);
        table.addCell(cell);
        table.addCell("1.1");
        table.addCell("2.1");
        table.addCell("3.1");
        table.addCell("1.2");
        table.addCell("2.2");
        table.addCell("3.2");

        cell = new PdfPCell(new Paragraph("cell test1"));
        table.addCell(cell);

        cell = new PdfPCell(new Paragraph("cell test2"));
        cell.setColspan(2);
        table.addCell(cell);

        document.add(table);
    } catch (Exception e) {
        System.err.println(e.getMessage());
    }
    document.close();
}

From source file:Main.java

public static void main(String args[]) {
    try {//from  ww w  .  jav  a2 s . c  om
        MongoClient mongoClient = new MongoClient("localhost", 27017);
        DB db = mongoClient.getDB("test");
        System.out.println("Connect to database successfully");
        boolean auth = db.authenticate("myUserName", "myPassword".toCharArray());
        System.out.println("Authentication: " + auth);
        DBCollection coll = db.getCollection("mycol");
        System.out.println("Collection mycol selected successfully");
        BasicDBObject doc = new BasicDBObject("title", "MongoDB").append("description", "database")
                .append("likes", 100).append("url", "http://www.java2s.com");
        coll.insert(doc);
        System.out.println("Document inserted successfully");
    } catch (Exception e) {
        System.err.println(e.getClass().getName() + ": " + e.getMessage());
    }
}

From source file:idgs.SqlCliDriver.java

public static void main(String[] args) {
    String sql = null;//from  ww  w . ja  v  a 2s.  c  o m
    if (args.length > 0) {
        for (String s : args) {
            sql = (sql == null) ? s : sql + " " + s;
        }
    } else {
        System.out.println("please input sql.");
        System.exit(1);
    }

    try {
        System.out.println(sql);
        ResultSet resultSet = IdgsCliDriver.run(sql);
        if (resultSet == null) {
            System.exit(2);
        } else {
            System.out.println(resultSet.toString());
        }

        System.exit(0);
    } catch (Exception e) {
        LOG.error(e.getMessage(), e);
        e.printStackTrace();
        System.exit(1);
    }
}

From source file:ZapfDingbatsNumberLists.java

public static void main(String[] args) {
    Document document = new Document();
    try {//from   w  w w . jav  a 2  s  .  c  o m
        PdfWriter.getInstance(document, new FileOutputStream("ZapfDingbatsNumberLists.pdf"));
        document.open();

        ZapfDingbatsNumberList z0 = new ZapfDingbatsNumberList(0, 15);
        z0.add(new ListItem("first item"));
        z0.add(new ListItem("second item"));
        document.add(z0);

        ZapfDingbatsNumberList z1 = new ZapfDingbatsNumberList(1, 15);
        z1.add(new ListItem("first item"));
        z1.add(new ListItem("second item"));
        document.add(z1);

        ZapfDingbatsNumberList z2 = new ZapfDingbatsNumberList(2, 15);
        z2.add(new ListItem("first item"));
        z2.add(new ListItem("second item"));
        document.add(z2);

        ZapfDingbatsNumberList z3 = new ZapfDingbatsNumberList(3, 15);
        z3.add(new ListItem("first item"));
        z3.add(new ListItem("second item"));
        document.add(z3);
    } catch (Exception ioe) {
        System.err.println(ioe.getMessage());
    }
    document.close();
}

From source file:OutlineActionsRemotePDF.java

public static void main(String[] args) {
    Document document = new Document();
    Document remote = new Document();
    try {//from  w w  w  .j av  a2 s  .  c  o m
        PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream("OutlineActionsRemotePDF.pdf"));
        PdfWriter.getInstance(remote, new FileOutputStream("remote.pdf"));

        writer.setViewerPreferences(PdfWriter.PageModeUseOutlines);
        remote.open();
        document.open();
        document.add(new Paragraph("Outline action example"));

        PdfContentByte cb = writer.getDirectContent();
        PdfOutline root = cb.getRootOutline();
        PdfOutline links = new PdfOutline(root, new PdfAction("http://www.java2s.com"), "Useful links");

        new PdfOutline(root, new PdfAction("remote.pdf", 1), "Go to yhe first page of a remote file");
        new PdfOutline(root, new PdfAction("remote.pdf", "test"), "Go to a local destination in a remote file");

        remote.add(new Paragraph("Text"));
        remote.newPage();
        Paragraph p = new Paragraph("This paragraph contains a ");
        p.add(new Chunk("local destination").setLocalDestination("test"));
        remote.add(p);

    } catch (Exception ioe) {
        System.err.println(ioe.getMessage());
    }
    document.close();
    remote.close();
}

From source file:base64test.Base64Test.java

/**
 * @param args the command line arguments
 *///from  w  w w.j a  v a  2  s .com
public static void main(String[] args) {
    try {
        if (!Base64.isBase64(args[0])) {
            throw new Exception("Arg 1 is not a Base64 string!");
        } else {
            String decodedBase64String = new String(Base64.decodeBase64(args[0]));
            File tempFile = File.createTempFile("base64Test", ".tmp");
            tempFile.deleteOnExit();
            FileWriter fw = new FileWriter(tempFile, false);
            PrintWriter pw = new PrintWriter(fw);
            pw.write(decodedBase64String);
            pw.close();
            String fileType = getFileType(tempFile.toPath());
            System.out.println(fileType);
            System.in.read();
        }
    } catch (Exception e) {
        System.err.println(e.getMessage());
    }
}

From source file:com.apress.prospringintegration.springenterprise.stocks.runner.MainTxAop.java

public static void main(String[] args) throws Exception {
    GenericApplicationContext context = new AnnotationConfigApplicationContext(
            "com.apress.prospringintegration.springenterprise.stocks.transactions.aopdeclarative",
            "com.apress.prospringintegration.springenterprise.stocks.dao.hibernate");

    StockBrokerService broker = context.getBean("aopStockBrokerService", StockBrokerService.class);
    try {//from  w  ww . j  a v  a  2  s . c  o m
        broker.preFillStocks("QQQQ", "INTC", "IBM", "XLA", "MGM", "C");
    } catch (Exception ex) {
        System.out.println("Exception: " + ex.getMessage());
    }

    StockDao stockDao = context.getBean(HibernateStockDao.class);
    System.out.println("Total rows inserted: " + stockDao.get().size());
    for (Stock s : stockDao.get()) {
        System.out.println("Stock added: " + s.getSymbol());
    }
}

From source file:com.apress.prospringintegration.springenterprise.stocks.runner.MainTxAnnotation.java

public static void main(String[] args) throws Exception {
    GenericApplicationContext context = new AnnotationConfigApplicationContext(
            "com.apress.prospringintegration.springenterprise.stocks.transactions.annotation",
            "com.apress.prospringintegration.springenterprise.stocks.dao.hibernate");

    StockBrokerService broker = context.getBean("annotationTxStockBrokerService", StockBrokerService.class);
    try {//from w w w  . j  av a 2s .com
        broker.preFillStocks("QQQQ", "INTC", "IBM", "XLA", "MGM", "C");
    } catch (Exception ex) {
        System.out.println("Exception: " + ex.getMessage());
    }

    StockDao stockDao = context.getBean(HibernateStockDao.class);
    System.out.println("Total rows inserted: " + stockDao.get().size());
    for (Stock s : stockDao.get()) {
        System.out.println("Stock added: " + s.getSymbol());
    }
}