Example usage for java.lang ClassNotFoundException getMessage

List of usage examples for java.lang ClassNotFoundException getMessage

Introduction

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

Prototype

public String getMessage() 

Source Link

Document

Returns the detail message string of this throwable.

Usage

From source file:MyClass.java

public static void main(String[] args) {
    try {/*from   www  .  j a va 2 s . co m*/
        String className = "MyClass";
        boolean initialize = false;

        ClassLoader cLoader = Main.class.getClassLoader();
        Class c = Class.forName(className, initialize, cLoader);
        className = "MyClass";
        System.out.println("about to load");
        // Will load and initialize the class
        c = Class.forName(className);
    } catch (ClassNotFoundException e) {
        System.out.println(e.getMessage());
    }
}

From source file:CreateCoffees.java

public static void main(String args[]) {
    String url = "jdbc:mySubprotocol:myDataSource";
    Connection con;/*from  w w  w. j  a  v a 2  s .com*/
    String createString;
    createString = "create table COFFEES " + "(COF_NAME VARCHAR(32), " + "SUP_ID INTEGER, " + "PRICE FLOAT, "
            + "SALES INTEGER, " + "TOTAL INTEGER)";
    Statement stmt;

    try {
        Class.forName("myDriver.ClassName");
    } catch (java.lang.ClassNotFoundException e) {
        System.err.print("ClassNotFoundException: ");
        System.err.println(e.getMessage());
    }

    try {
        con = DriverManager.getConnection(url, "myLogin", "myPassword");
        stmt = con.createStatement();
        stmt.executeUpdate(createString);
        stmt.close();
        con.close();

    } catch (SQLException ex) {
        System.err.println("SQLException: " + ex.getMessage());
    }
}

From source file:CreateCoffees.java

public static void main(String args[]) {

    String url = "jdbc:mySubprotocol:myDataSource";
    Connection con;/*w  w  w. j a v a 2  s  .co  m*/
    String createString;
    createString = "create table COFFEES " + "(COF_NAME varchar(32), " + "SUP_ID int, " + "PRICE float, "
            + "SALES int, " + "TOTAL int)";
    Statement stmt;

    try {
        Class.forName("myDriver.ClassName");

    } catch (java.lang.ClassNotFoundException e) {
        System.err.print("ClassNotFoundException: ");
        System.err.println(e.getMessage());
    }

    try {
        con = DriverManager.getConnection(url, "myLogin", "myPassword");

        stmt = con.createStatement();
        stmt.executeUpdate(createString);

        stmt.close();
        con.close();

    } catch (SQLException ex) {
        System.err.println("SQLException: " + ex.getMessage());
    }
}

From source file:CreateSuppliers.java

public static void main(String args[]) {
    String url = "jdbc:mySubprotocol:myDataSource";
    Connection con;//from  w  w w .ja  v  a2  s  .c  o  m
    String createString;
    createString = "create table SUPPLIERS " + "(SUP_ID int, " + "SUP_NAME varchar(40), "
            + "STREET varchar(40), " + "CITY varchar(20), " + "STATE char(2), ZIP char(5))";

    Statement stmt;

    try {
        Class.forName("myDriver.ClassName");

    } catch (java.lang.ClassNotFoundException e) {
        System.err.print("ClassNotFoundException: ");
        System.err.println(e.getMessage());
    }

    try {
        con = DriverManager.getConnection(url, "myLogin", "myPassword");

        stmt = con.createStatement();
        stmt.executeUpdate(createString);

        stmt.close();
        con.close();

    } catch (SQLException ex) {
        System.err.println("SQLException: " + ex.getMessage());
    }
}

From source file:CreateStores.java

public static void main(String args[]) {

    String url = "jdbc:mySubprotocol:myDataSource";
    Connection con;//from  w ww  .  j a v a2s. c  o  m
    String createTable;
    String createArray;
    createArray = "CREATE TYPE COF_ARRAY AS ARRAY(10) OF VARCHAR(40)";
    createTable = "CREATE TABLE STORES ( " + "STORE_NO INTEGER, LOCATION ADDRESS, "
            + "COF_TYPES COF_ARRAY, MGR REF MANAGER )";
    Statement stmt;

    try {
        Class.forName("myDriver.ClassName");

    } catch (java.lang.ClassNotFoundException e) {
        System.err.print("ClassNotFoundException: ");
        System.err.println(e.getMessage());
    }

    try {
        con = DriverManager.getConnection(url, "myLogin", "myPassword");

        stmt = con.createStatement();

        stmt.executeUpdate(createArray);
        stmt.executeUpdate(createTable);

        stmt.close();
        con.close();

    } catch (SQLException ex) {
        System.err.println("SQLException: " + ex.getMessage());
    }
}

From source file:TableTypes.java

public static void main(String args[]) {

    String url = "jdbc:mySubprotocol:myDataSource";
    Connection con;/*from   w  w w.ja v a  2s.  c  o  m*/

    try {
        Class.forName("myDriver.ClassName");

    } catch (java.lang.ClassNotFoundException e) {
        System.err.print("ClassNotFoundException: ");
        System.err.println(e.getMessage());
    }

    try {
        con = DriverManager.getConnection(url, "myLogin", "myPassword");

        DatabaseMetaData dbmd = con.getMetaData();
        String dbmsName = dbmd.getDatabaseProductName();
        ResultSet rs = dbmd.getTableTypes();
        System.out.print("The following types of tables are ");
        System.out.println("available in " + dbmsName + ":  ");

        while (rs.next()) {
            String tableType = rs.getString("TABLE_TYPE");
            System.out.println("    " + tableType);
        }

        rs.close();
        con.close();

    } catch (SQLException ex) {
        System.err.print("SQLException: ");
        System.err.println(ex.getMessage());
    }
}

From source file:Join.java

public static void main(String args[]) {

    String url = "jdbc:mySubprotocol:myDataSource";
    Connection con;//from w  ww  .  j  a  v a 2  s  .  co m
    String query = "select SUPPLIERS.SUP_NAME, COFFEES.COF_NAME " + "from COFFEES, SUPPLIERS "
            + "where SUPPLIERS.SUP_NAME like 'Acme, Inc.' and " + "SUPPLIERS.SUP_ID = COFFEES.SUP_ID";
    Statement stmt;

    try {
        Class.forName("myDriver.ClassName");

    } catch (java.lang.ClassNotFoundException e) {
        System.err.print("ClassNotFoundException: ");
        System.err.println(e.getMessage());
    }

    try {
        con = DriverManager.getConnection(url, "myLogin", "myPassword");

        stmt = con.createStatement();

        ResultSet rs = stmt.executeQuery(query);
        System.out.println("Supplier, Coffee:");
        while (rs.next()) {
            String supName = rs.getString(1);
            String cofName = rs.getString(2);
            System.out.println("    " + supName + ", " + cofName);
        }

        stmt.close();
        con.close();

    } catch (SQLException ex) {
        System.err.print("SQLException: ");
        System.err.println(ex.getMessage());
    }
}

From source file:com.predic8.membrane.core.RouterCLI.java

public static void main(String[] args) throws ParseException {

    MembraneCommandLine cl = new MembraneCommandLine();
    cl.parse(args);/*from w  w  w  .jav  a2s .  c  o  m*/
    if (cl.needHelp()) {
        cl.printUsage();
        return;
    }

    try {
        Router.init(getConfigFile(cl), RouterCLI.class.getClassLoader()).getConfigurationManager()
                .loadConfiguration(getRulesFile(cl));
        //System.out.println("preloading cache...");
        //ApplicationCachePreLoader.init();
    } catch (ClassNotFoundException e) {

        e.printStackTrace();

    } catch (PortOccupiedException e) {
        System.err.println(e.getMessage());
        System.exit(1);
    } catch (Exception ex) {
        ex.printStackTrace();
        System.err.println(
                "Could not read rules configuration. Please specify a file containing rules using the -c command line option. Or make sure that the file "
                        + System.getenv("MEMBRANE_HOME") + "/conf/rules.xml exists");
        System.exit(1);
    }

    new RouterCLI().waitForever();

}

From source file:CreateUDTs.java

public static void main(String args[]) {

    String url = "jdbc:mySubprotocol:myDataSource";
    Connection con;//from  www  .ja v  a  2s  . c  o  m
    Statement stmt;

    String createAddress = "CREATE TYPE ADDRESS (NUM INTEGER, " + "STREET VARCHAR(40), CITY VARCHAR(40), "
            + "STATE CHAR(2), ZIP CHAR(5))";

    String createManager = "CREATE TYPE MANAGER (MGR_ID INTEGER, "
            + "LAST_NAME VARCHAR(40), FIRST_NAME VARCHAR(40), " + "PHONE char(10))";

    try {

        Class.forName("myDriver.ClassName");

    } catch (java.lang.ClassNotFoundException e) {
        System.err.print("ClassNotFoundException: ");
        System.err.println(e.getMessage());
    }

    try {
        con = DriverManager.getConnection(url, "myLogin", "myPassword");

        stmt = con.createStatement();

        stmt.executeUpdate(createAddress);
        stmt.executeUpdate("CREATE TYPE PHONE_NO AS CHAR(10)");
        stmt.executeUpdate(createManager);

        stmt.close();
        con.close();

    } catch (SQLException ex) {
        System.err.println("-----SQLException-----");
        System.err.println("SQLState:  " + ex.getSQLState());
        System.err.println("Message:  " + ex.getMessage());
        System.err.println("Vendor:  " + ex.getErrorCode());
    }
}

From source file:SQLStatement.java

public static void main(String args[]) {

    String url = "jdbc:mySubprotocol:myDataSource";
    Connection con;/*w  ww . j ava  2 s .co  m*/
    String query = "select SUPPLIERS.SUP_NAME, COFFEES.COF_NAME " + "from COFFEES, SUPPLIERS "
            + "where SUPPLIERS.SUP_NAME like 'Acme, Inc.' and " + "SUPPLIERS.SUP_ID = COFFEES.SUP_ID";
    Statement stmt;

    try {
        Class.forName("myDriver.ClassName");

    } catch (java.lang.ClassNotFoundException e) {
        System.err.print("ClassNotFoundException: ");
        System.err.println(e.getMessage());
    }

    try {
        con = DriverManager.getConnection(url, "myLogin", "myPassword");

        stmt = con.createStatement();

        ResultSet rs = stmt.executeQuery(query);
        ResultSetMetaData rsmd = rs.getMetaData();
        int numberOfColumns = rsmd.getColumnCount();
        int rowCount = 1;
        while (rs.next()) {
            System.out.println("Row " + rowCount + ":  ");
            for (int i = 1; i <= numberOfColumns; i++) {
                System.out.print("   Column " + i + ":  ");
                System.out.println(rs.getString(i));
            }
            System.out.println("");
            rowCount++;
        }
        stmt.close();
        con.close();

    } catch (SQLException ex) {
        System.err.print("SQLException: ");
        System.err.println(ex.getMessage());
    }
}