Example usage for java.lang ClassNotFoundException printStackTrace

List of usage examples for java.lang ClassNotFoundException printStackTrace

Introduction

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

Prototype

public void printStackTrace() 

Source Link

Document

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

Usage

From source file:org.seamless_ip.services.dao.IndicatorDaoImpl.java

@SuppressWarnings("unchecked")
public IIndicatorTO findById(String dbClassName, Long id) {
    try {/*from  ww  w .  j  a v a 2 s.  c  o m*/
        Class<?> dbClass = Class.forName(dbClassName);
        Object dbItem = currentSession().get(dbClass, id);
        return createTO(dbItem);
    } catch (ClassNotFoundException e) {
        e.printStackTrace();
    }
    return null;
}

From source file:dgw.mt940.db.util.DGWBasicDataSource.java

public DataSource initDGWBasicDataSource() {
    // First we set up the BasicDataSource.
    // Normally this would be handled auto-magically by
    // an external configuration, but in this example we'll
    // do it manually.
    //// ww w .  j  a v  a  2 s.  c  o m
    logger4j.debug("Setting up data source.");
    String connURL = ConfigUtil.getConfigUtil().getConfig("jdbc.dgw.url");
    String driver = ConfigUtil.getConfigUtil().getConfig("jdbc.dgw.driverClassName");
    String userName = ConfigUtil.getConfigUtil().getConfig("jdbc.dgw.username");
    String password = ConfigUtil.getConfigUtil().getConfig("jdbc.dgw.password");
    String removeAbandoned = ConfigUtil.getConfigUtil().getConfig("jdbc.dgw.pool.removeAbandoned");
    String initSize = ConfigUtil.getConfigUtil().getConfig("jdbc.dgw.pool.initial.size");
    String maxIdle = ConfigUtil.getConfigUtil().getConfig("jdbc.dgw.pool.max.size");
    try {
        Class.forName(driver);
    } catch (ClassNotFoundException e) {
        e.printStackTrace();
    }
    dataSource = setupDataSource(connURL, driver, userName, password, removeAbandoned, initSize, maxIdle);
    logger4j.debug("Done.");

    return dataSource;
}

From source file:dgw.mt940.db.util.DGWBasicDataSource.java

public DataSource initPMMBasicDataSource() {
    // First we set up the BasicDataSource.
    // Normally this would be handled auto-magically by
    // an external configuration, but in this example we'll
    // do it manually.
    ///*from   w ww  .  j  a va2 s  . co  m*/
    logger4j.debug("Setting up data source.");
    String connURL = ConfigUtil.getConfigUtil().getConfig("jdbc.pmm.url");
    String driver = ConfigUtil.getConfigUtil().getConfig("jdbc.pmm.driverClassName");
    String userName = ConfigUtil.getConfigUtil().getConfig("jdbc.pmm.username");
    String password = ConfigUtil.getConfigUtil().getConfig("jdbc.pmm.password");
    String removeAbandoned = ConfigUtil.getConfigUtil().getConfig("jdbc.pmm.pool.removeAbandoned");
    String initSize = ConfigUtil.getConfigUtil().getConfig("jdbc.pmm.pool.initial.size");
    String maxIdle = ConfigUtil.getConfigUtil().getConfig("jdbc.pmm.pool.max.size");
    try {
        Class.forName(driver);
    } catch (ClassNotFoundException e) {
        e.printStackTrace();
    }
    dataSource = setupDataSource(connURL, driver, userName, password, removeAbandoned, initSize, maxIdle);
    logger4j.debug("Done.");

    return dataSource;
}

From source file:dgw.mt940.db.util.DGWBasicDataSource.java

public DataSource initTMBCIBasicDataSource() {
    // First we set up the BasicDataSource.
    // Normally this would be handled auto-magically by
    // an external configuration, but in this example we'll
    // do it manually.
    ///*  w  ww .ja  va  2  s . c  o m*/
    logger4j.debug("Setting up data source.");
    String connURL = ConfigUtil.getConfigUtil().getConfig("jdbc.tmbci.url");
    String driver = ConfigUtil.getConfigUtil().getConfig("jdbc.tmbci.driverClassName");
    String userName = ConfigUtil.getConfigUtil().getConfig("jdbc.tmbci.username");
    String password = ConfigUtil.getConfigUtil().getConfig("jdbc.tmbci.password");
    String removeAbandoned = ConfigUtil.getConfigUtil().getConfig("jdbc.tmbci.pool.removeAbandoned");
    String initSize = ConfigUtil.getConfigUtil().getConfig("jdbc.tmbci.pool.initial.size");
    String maxIdle = ConfigUtil.getConfigUtil().getConfig("jdbc.tmbci.pool.max.size");
    try {
        Class.forName(driver);
    } catch (ClassNotFoundException e) {
        e.printStackTrace();
    }
    dataSource = setupDataSource(connURL, driver, userName, password, removeAbandoned, initSize, maxIdle);
    logger4j.debug("Done.");

    return dataSource;
}

From source file:fr.gael.dhus.gwt.GWTWebapp.java

@Override
public void init() {
    this.name = "";
    this.servlets = new ArrayList<WebServlet>();
    this.welcomeFiles = new ArrayList<String>();

    servlets.add(new GWTClientWebServlet("home", "/home"));

    welcomeFiles.add("home");

    ClassPathScanningCandidateComponentProvider scan = new ClassPathScanningCandidateComponentProvider(false);
    scan.addIncludeFilter(new AnnotationTypeFilter(RPCService.class));
    logger.info("    Initializing RPC services");
    for (BeanDefinition bd : scan.findCandidateComponents("fr.gael.dhus.gwt.services")) {
        logger.info("     - service : " + bd.getBeanClassName());
        try {/*  w  w  w .  j  a  v a 2  s  .  co m*/
            Class<?> servletClass = GWTWebapp.class.getClassLoader().loadClass(bd.getBeanClassName());
            RPCService annotation = AnnotationUtils.findAnnotation(servletClass, RPCService.class);
            servlets.add(new RPCServlet((Servlet) (servletClass.newInstance()), annotation.value(),
                    "/" + annotation.value()));
        } catch (ClassNotFoundException e) {
            System.err.println("Cannot load service : '" + bd.getBeanClassName() + "'");
            e.printStackTrace();
        } catch (InstantiationException e) {
            e.printStackTrace();
        } catch (IllegalAccessException e) {
            e.printStackTrace();
        }
    }
}

From source file:org.seamless_ip.services.dao.IndicatorDaoImpl.java

@SuppressWarnings("unchecked")
public Collection<IIndicatorTO> findAll(String dbClassName) {
    ArrayList<IIndicatorTO> result = new ArrayList<IIndicatorTO>();
    try {//from w  ww  .ja v  a  2  s. co m
        Class<?> dbClass = Class.forName(dbClassName);
        Collection<Object> dbItems = currentSession().createCriteria(dbClass).list();
        for (Object dbItem : dbItems)
            result.add(createTO(dbItem));
    } catch (ClassNotFoundException e) {
        e.printStackTrace();
    }
    return result;
}

From source file:fitmon.WorkoutData.java

public double calBurned(String date, int userId) throws SQLException {
    PreparedStatement st = null;//from www .j  av a 2s .c  o  m
    Connection conn = null;
    double calBurned = 0;
    try {
        String query = "select date,sum(calories) from Workout where userId=" + userId + " and date='" + date
                + "'";
        Class.forName("com.mysql.jdbc.Driver");
        conn = (Connection) DriverManager.getConnection("jdbc:mysql://localhost:3306/fitmon", "root",
                "april-23");
        st = conn.prepareStatement(query);
        conn.setAutoCommit(false);
        ResultSet rs = st.executeQuery(query);
        while (rs.next()) {

            calBurned = rs.getDouble("sum(calories)");

        }
        st.close();
        conn.close();

    } catch (ClassNotFoundException ce) {
        ce.printStackTrace();
    } catch (SQLException se) {
        se.printStackTrace();
    } catch (Exception e) {
        //Handle errors for Class.forName
        e.printStackTrace();
    } finally {

        if (st != null) {
            st.close();
        }

        if (conn != null) {
            conn.close();
        }

    }
    return calBurned;
}

From source file:fitmon.WorkoutData.java

public ArrayList<ArrayList> getTotalCaloriesBurned(int userId) throws SQLException {
    PreparedStatement st = null;/*from   w w  w  .j a v a 2  s.c o  m*/
    Connection conn = null;
    ArrayList<ArrayList> calBurnedList = new ArrayList<ArrayList>();
    try {
        String query = "select date,sum(calories) from Workout where userId=" + userId
                + " group by date limit 5";
        Class.forName("com.mysql.jdbc.Driver");
        conn = (Connection) DriverManager.getConnection("jdbc:mysql://localhost:3306/fitmon", "root",
                "april-23");
        st = conn.prepareStatement(query);
        conn.setAutoCommit(false);

        ArrayList calBurned = new ArrayList();
        ResultSet rs = st.executeQuery(query);
        while (rs.next()) {
            calBurned = new ArrayList();
            calBurned.add(rs.getString("date"));
            calBurned.add(rs.getDouble("sum(calories)"));
            calBurnedList.add(calBurned);
        }
        st.close();
        conn.close();

    } catch (ClassNotFoundException ce) {
        ce.printStackTrace();
    } catch (SQLException se) {
        se.printStackTrace();
    } catch (Exception e) {
        //Handle errors for Class.forName
        e.printStackTrace();
    } finally {

        if (st != null) {
            st.close();
        }

        if (conn != null) {
            conn.close();
        }

    }

    return calBurnedList;
}

From source file:org.seamless_ip.services.dao.IndicatorDaoImpl.java

@SuppressWarnings("unchecked")
public Collection<IIndicatorTO> findByProblemId(Long problemId) {
    ArrayList<IIndicatorTO> result = new ArrayList<IIndicatorTO>();

    Query q = query("from Problem as p where p.id = :id").setParameter("id", problemId);
    Problem problem = (Problem) q.uniqueResult();
    if (problem != null) {
        try {/*from  w ww. ja  va  2 s .  c  om*/
            for (IIndicator dbItem : problem.getIndicators())
                result.add(createTO(dbItem));
        } catch (ClassNotFoundException e) {
            e.printStackTrace();
        }
    }
    return result;
}

From source file:fr.xebia.ws.travel.antifraud.v1_0.AntiFraudServiceImpl.java

private boolean checkDbOnline() {
    try {/*w  w w  .  j a v a 2  s.  c o  m*/
        Class.forName("org.hsqldb.jdbc.JDBCDriver");
        Class.forName("com.mysql.jdbc.Driver");
    } catch (ClassNotFoundException e1) {
        e1.printStackTrace();
    }
    try {
        DriverManager.setLoginTimeout(60);
        Connection connection = DriverManager.getConnection(jdbcUrl, user, password);
        Statement statement = connection.createStatement();
        ResultSet resultSet = statement.executeQuery("SELECT 1 FROM fraud");
        resultSet.next();
        resultSet.close();
        statement.close();
        connection.close();

    } catch (Exception e) {
        return false;
    }

    return true;
}