List of usage examples for java.lang ClassNotFoundException printStackTrace
public void printStackTrace()
From source file:architecture.ee.spring.context.impl.ApplicationHelperImpl.java
@SuppressWarnings("rawtypes") public Object getInstance(Object obj) { if (getConfigurableApplicationContext() == null) { throw new IllegalStateException(); }/* www .j ava 2 s .co m*/ if (obj instanceof String) { try { Class clazz = getConfigurableApplicationContext().getClassLoader().loadClass((String) obj); return createComponent(clazz); } catch (ClassNotFoundException e) { e.printStackTrace(); } } return null; }
From source file:com.anyuan.thomweboss.persistence.jdbcimpl.BaseDaoJdbcImpl.java
@Override public Connection getConnection() { String driver = "org.postgresql.Driver"; String url = "jdbc:postgresql://127.0.0.1:5432/thomdb"; // String driver = "com.mysql.jdbc.Driver"; // String url = "jdbc:mysql://localhost:3306/thomdb"; String username = "thomoss"; String password = "ossthom"; Connection connection = null; BasicDataSource dataSource = new BasicDataSource(); // dataSource.setDriverClassName("org.postgresql.Driver"); // dataSource.setUrl("jdbc:postgresql://127.0.0.1:5432/thomdb"); // dataSource.setUsername("thomoss"); // dataSource.setPassword("ossthom"); // /home/thom/workspace/thomweboss/target/classes/ // String path = this.getClass().getClassLoader().getResource("").toString(); String path = Thread.currentThread().getContextClassLoader().getResource("").toString(); // try { // String path = this.getClass().getClassLoader().getResource("").toString(); // InputStream inStream = new FileInputStream(path + "../properties/jdbc.properties"); // Properties properties = new Properties(); // properties.load(inStream); // inStream.close(); // } catch (FileNotFoundException e1) { // e1.printStackTrace(); // } catch (IOException e1) { // e1.printStackTrace(); // }// w w w. j a va2 s . c om // try { // dataSource.setConnectionProperties(path + "../properties/jdbc.properties"); // System.out.print(path + "../properties/jdbc.properties"); // connection = dataSource.getConnection(); // } catch (SQLException e) { // e.printStackTrace(); // } // jdbc connection try { Class.forName(driver); connection = DriverManager.getConnection(url, username, password); } catch (ClassNotFoundException e) { e.printStackTrace(); } catch (SQLException e) { e.printStackTrace(); } if (null == connection) { throw new NullPointerException("?"); } else { return connection; } }
From source file:com.naver.timetable.jdbc.CubridDataManager.java
/** * jdbc? ?? .//from w ww . j a va2 s . c o m * @param strDriver * @param strDBConn * @param strUserID * @param strUserPW */ public void initDriver() { try { Class.forName(strDriver); Connection objConn = DriverManager.getConnection(strDBConn, strUserID, strUserPW); } catch (ClassNotFoundException e) { e.printStackTrace(); } catch (SQLException e) { e.printStackTrace(); } // ? ? . AbandonedConfig abandonedConfig = new AbandonedConfig(); abandonedConfig.setRemoveAbandoned(true); AbandonedObjectPool connectionPool = new AbandonedObjectPool(null, abandonedConfig); connectionPool.setMaxActive(maxActive); connectionPool.setMaxIdle(maxIdle); connectionPool.setMinIdle(minIdle); connectionPool.setTimeBetweenEvictionRunsMillis(timeBetweenEvictionRunsMillis); // connectionPool.setMinEvictableIdleTimeMillis(minEvictableIdleTimeMillis); ConnectionFactory driverConnFactory = new DriverManagerConnectionFactory(strDBConn, strUserID, strUserPW); PoolableConnectionFactory connFactory = new PoolableConnectionFactory(driverConnFactory, connectionPool, null, null, defaultReadOnly, defaultAutoCommit); PoolingDataSource pds = new PoolingDataSource(connectionPool); dataSource = pds; try { for (int i = 0; i < initialSize; i++) { connectionPool.addObject(); } } catch (Exception e) { e.printStackTrace(); } }
From source file:com.oakhole.Generate.java
/** * ?Entity/*from w w w . ja v a 2 s .c o m*/ * @param filePath * @param entities */ private void fetchEntities(String packageName, String filePath, Set<Class<?>> entities) { // package File file = new File(filePath); if (!file.exists() || !file.isDirectory()) { logger.warn("{} neither exists nor the directory .", filePath); return; } // ?packageclass File[] subFiles = file.listFiles(new FileFilter() { @Override public boolean accept(File pathname) { return pathname.isDirectory() || pathname.getName().endsWith(".class"); } }); for (File subFile : subFiles) { // ?class? if (subFile.isDirectory()) { fetchEntities(packageName + "." + subFile.getName(), subFile.getAbsolutePath(), entities); } else { // ?? String className = subFile.getName().substring(0, subFile.getName().length() - 6); try { Class object = Thread.currentThread().getContextClassLoader() .loadClass(packageName + "." + className); if (object.getAnnotation(Entity.class) != null) { entities.add(object); } } catch (ClassNotFoundException e) { e.printStackTrace(); } } } }
From source file:com.softberries.klerk.dao.PeopleDao.java
@Override public Person find(Long id) throws SQLException { try {/*from w w w . j av a 2 s. com*/ init(); return this.find(id, run, conn, st, generatedKeys); } catch (ClassNotFoundException e) { e.printStackTrace(); } finally { close(conn, st, generatedKeys); } return null; }
From source file:org.apache.hadoop.hive.ql.metadata.MetaStore.java
public Connection openConnect() { try {// w ww . ja va 2 s.c o m Class.forName("com.mysql.jdbc.Driver"); } catch (ClassNotFoundException e) { LOG.error(" get com.mysql.jdbc.Driver failed! "); e.printStackTrace(); } Connection conn = null; try { LOG.info(" Connecting: " + url); DriverManager.setLoginTimeout(waittime); conn = DriverManager.getConnection(url, this.prop); LOG.info(" get Connection ok: " + url); } catch (SQLException e) { LOG.error(" get Connection failed: " + url); e.printStackTrace(); } return conn; }
From source file:com.softberries.klerk.dao.CompanyDao.java
@Override public Company find(Long id) throws SQLException { try {// www . ja v a 2 s.co m init(); return this.find(id, run, conn, st, generatedKeys); } catch (ClassNotFoundException e) { e.printStackTrace(); } finally { close(conn, st, generatedKeys); } return null; }
From source file:com.softberries.klerk.dao.PeopleDao.java
@Override public List<Person> findAll() throws SQLException { List<Person> people = new ArrayList<Person>(); try {/* w w w . j a va 2s.c o m*/ init(); ResultSetHandler<List<Person>> h = new BeanListHandler<Person>(Person.class); people = run.query(conn, SQL_FIND_PERSON_ALL, h); // find addresses AddressDao adrDao = new AddressDao(); for (Person c : people) { c.setAddresses(adrDao.findAllByPersonId(c.getId(), run, conn)); } } catch (ClassNotFoundException e) { e.printStackTrace(); } finally { close(conn, st, generatedKeys); } return people; }
From source file:edu.br.tcc.ManagedBean.TrabalhosBean.java
public void Corrigir(Formulario trabalho) { System.out.println("entrou no mtodo corrigir do mb"); try {// w ww . jav a 2 s. c o m System.out.println("id: " + trabalho.getId_nome()); this.formulariodao = new FormularioDAO(); boolean corrige = this.formulariodao.atualizaFormulario(trabalho); if (corrige) { this.formulariodao = new FormularioDAO(); pedidoListarTrabalho(); FacesMessage mensagem = new FacesMessage("Trabalho Corrigido"); FacesContext.getCurrentInstance().addMessage(null, mensagem); } else { FacesMessage mensagem = new FacesMessage("Falha na Correo"); FacesContext.getCurrentInstance().addMessage(null, mensagem); } } catch (ClassNotFoundException ex) { ex.printStackTrace(); Logger.getLogger(BibliotecarioBean.class.getName()).log(Level.SEVERE, null, ex); } }
From source file:org.alfresco.custom.constraint.db.DatabaseImpl.java
/** * @see org.alfresco.custom.database.Database#getConnetion() *///from w w w .java 2 s . c om @Override public void getConnetion() { try { Class.forName(this.driver); logger.debug("Driver Loaded successfully"); this.conn = DriverManager.getConnection(this.url, this.user, this.pwd); logger.debug("Connection created successfully"); } catch (ClassNotFoundException e) { logger.error("Error when try to load driver. Check if JDBC are in the classpath"); e.printStackTrace(); } catch (SQLException e) { logger.error("Error when try to create connection. Check if the parameters [url=" + this.url + " user=" + this.user + " pwd=" + this.pwd + "]"); e.printStackTrace(); } }