List of usage examples for javax.naming NamingException printStackTrace
public void printStackTrace()
From source file:eu.supersede.dm.ModuleLoader.java
@PostConstruct public void init() { DMGame.JpaProvider jpa = new DMGame.JpaProvider(); jpa.activities = jpaActivities;/*w ww . j a v a2 s . co m*/ jpa.criteria = jpaCriteria; jpa.members = jpaMembers; jpa.processes = jpaProcesses; jpa.requirements = jpaRequirements; jpa.users = jpaUsers; jpa.processCriteria = jpaProcessCriteria; jpa.alerts = jpaAlerts; jpa.apps = jpaApps; jpa.receivedUserRequests = jpaReceivedUserRequests; jpa.requirementProperties = jpaRequirementProperties; jpa.requirementDependencies = jpaRequirementDependencies; jpa.properties = jpaProperties; jpa.propertyBags = jpaPropertyBags; jpa.requirementsRankings = requirementsRankings; jpa.scoresJpa = scores; jpa.proxy = proxy; DMGame.init(jpa); new Thread(new Runnable() { @Override public void run() { iEvolutionSubscriber subscriber = null; try { subscriber = new EvolutionSubscriber(); subscriber.openTopicConnection(); EvolutionAlertMessageListener messageListener = subscriber .createEvolutionAlertSubscriptionAndKeepListening(); try { while (true) { if (messageListener.areMessageReceived()) { handleAlert(messageListener.getNextAlert()); } else { Thread.sleep(1000); // FIXME Configure sleeping time } } } catch (InterruptedException e) { e.printStackTrace(); } subscriber.closeSubscription(); subscriber.closeTopicConnection(); } catch (JMSException e) { e.printStackTrace(); } catch (NamingException e1) { e1.printStackTrace(); } finally { if (subscriber != null) { try { subscriber.closeTopicConnection(); } catch (JMSException e) { throw new RuntimeException("Error in closing topic connection", e); } } } } }).start(); }
From source file:biz.taoconsulting.dominodav.resource.DAVResourceJDBC.java
/** * /**// w w w . j av a 2s .c o m * * @see biz.taoconsulting.dominodav.resource.DAVAbstractResource#getStream() */ public InputStream getStream() { Connection conn = null; Statement stmt = null; InputStream blobStream = null; try { Context initCtx = new InitialContext(); Context envCtx = (Context) initCtx.lookup("java:comp/env"); DataSource ds = (DataSource) // THe internal address of a JDBC source is the data source envCtx.lookup(this.repositoryMeta.getInternalAddress()); conn = ds.getConnection(); stmt = conn.createStatement(); // XXX: THat is plain wrong -- need to rework the JDBC data source // query ResultSet rs = stmt.executeQuery( "select f.fil_blocksize,f.fil_contents_blob from ibkuis_pp_files f where f.fil_id=" + this.getDBFileID()); if (rs.next()) { Blob blob = rs.getBlob(2); blobStream = blob.getBinaryStream(); } } catch (NamingException e) { e.printStackTrace(); } catch (SQLException e) { e.printStackTrace(); } finally { try { if (stmt != null) stmt.close(); if (conn != null) conn.close(); } catch (SQLException e) { /** Exception handling **/ } } return blobStream; }
From source file:catalina.mbeans.GlobalResourcesLifecycleListener.java
/** * Create the MBeans for the interesting global JNDI resources. *//*from w ww . j a v a2 s.c om*/ protected void createMBeans() { // Look up our global naming context Context context = null; try { context = (Context) (new InitialContext()).lookup("java:/"); } catch (NamingException e) { e.printStackTrace(); throw new IllegalStateException("No global naming context defined for server"); } // Recurse through the defined global JNDI resources context try { createMBeans("", context); } catch (NamingException e) { log("Exception processing Global JNDI Resources", e); } }
From source file:biz.taoconsulting.dominodav.resource.DAVResourceJDBC.java
private void getInitDBFileValues() { Statement stmt = null;// w w w.j av a 2 s . c om Statement stmt1 = null; Connection conn = null; try { Context initCtx = new InitialContext(); Context envCtx = (Context) initCtx.lookup("java:comp/env"); DataSource ds = (DataSource) envCtx.lookup(this.repositoryMeta.getInternalAddress()); conn = ds.getConnection(); stmt1 = conn.createStatement(); // TODO fix this stmt1.executeQuery("select uis_mid_onetimeinitweb('DATENADMIN','umsys','DE') as a from dual"); stmt = conn.createStatement(); // TODO: Fix that SQL ResultSet rs = stmt.executeQuery( "select t.dtyp_mimetype,d.*," + "f.fil_length,f.fil_id from umsys.ibkuis_co_filetype t," + "uis_pp_documents_v d, ibkuis_pp_files f where d.D_ID =" + this.getDBDocID() + "and f.fil_id = d.D_FIL_ID and t.dtyp_kz = upper(d.D_TYP)"); if (rs.next()) { this.setName(rs.getString("D_FILE")); this.setExtension(rs.getString("D_TYP")); this.setContentLength(rs.getString("FIL_LENGTH")); this.setDBFileID(rs.getString("FIL_ID")); this.setMimeType(rs.getString("dtyp_mimetype")); System.out.println("BREAK"); } } catch (NamingException e) { e.printStackTrace(); } catch (SQLException e) { e.printStackTrace(); } finally { try { if (stmt != null) stmt.close(); if (stmt1 != null) stmt1.close(); if (conn != null) conn.close(); } catch (SQLException e) { /** Exception handling **/ } } }
From source file:org.nuxeo.ecm.directory.ldap.MockLdapServer.java
public void createUser(String uid, String cn, String password) { Attributes user = new BasicAttributes("uid", uid); user.put("cn", cn); user.put("userPassword", password); Attribute objectClass = new BasicAttribute("objectClass"); user.put(objectClass);// ww w .j a v a 2 s . co m objectClass.add("top"); objectClass.add("person"); objectClass.add("organizationalPerson"); objectClass.add("inetOrgPerson"); user.put("sn", uid); try { serverContext.createSubcontext("uid=" + uid + ",ou=people", user); } catch (NameAlreadyBoundException ignore) { // System.out.println(" user " + uid + " already exists."); } catch (NamingException ne) { System.err.println("Failed to create user."); ne.printStackTrace(); } }
From source file:com.stratelia.silverpeas.versioning.jcr.impl.AbstractJcrTestCase.java
@Resource public void setDataSource(DataSource datasource) { this.datasource = datasource; try {//w w w. j a va2 s . co m prepareJndi(); Hashtable env = new Hashtable(); env.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.fscontext.RefFSContextFactory"); InitialContext ic = new InitialContext(env); Properties properties = new Properties(); properties.load(PathTestUtil.class.getClassLoader().getResourceAsStream("jdbc.properties")); // Construct BasicDataSource reference Reference ref = new Reference("javax.sql.DataSource", "org.apache.commons.dbcp.BasicDataSourceFactory", null); ref.add(new StringRefAddr("driverClassName", properties.getProperty("driverClassName", "org.postgresql.Driver"))); ref.add(new StringRefAddr("url", properties.getProperty("url", "jdbc:postgresql://localhost:5432/postgres"))); ref.add(new StringRefAddr("username", properties.getProperty("username", "postgres"))); ref.add(new StringRefAddr("password", properties.getProperty("password", "postgres"))); ref.add(new StringRefAddr("maxActive", "4")); ref.add(new StringRefAddr("maxWait", "5000")); ref.add(new StringRefAddr("removeAbandoned", "true")); ref.add(new StringRefAddr("removeAbandonedTimeout", "5000")); rebind(ic, JNDINames.DATABASE_DATASOURCE, ref); rebind(ic, JNDINames.ADMIN_DATASOURCE, ref); } catch (NamingException nex) { nex.printStackTrace(); } catch (IOException nex) { nex.printStackTrace(); } }
From source file:com.emc.plants.service.impl.ReportGeneratorBean.java
/** * Run the report to get the top zip codes for a range of dates. * * @param startdate Start of date range. * @param enddate End of date range./* w ww .jav a2 s . co m*/ * @param quantity Number of items to return in report. * @param reportFormat - Report format information. * @return Report containing results. */ @SuppressWarnings("unchecked") public Report getTopSellingZipsForDates(java.util.Date startdate, java.util.Date enddate, int quantity, ReportFormat reportFormat) { Report report = null; Connection conn = null; ResultSet results = null; PreparedStatement sqlStatement = null; try { // Establish connection to datasource. String orderInfoTableName = "ORDER1"; DataSource ds = (DataSource) Util.getInitialContext().lookup("jdbc/PlantsByWebSphereDataSource"); conn = ds.getConnection(); // Set sort order of ascending or descending. String sortOrder; if (reportFormat.isAscending()) sortOrder = "ASC"; else sortOrder = "DESC"; // Set up where by clause. String startDateString = Long.toString(startdate.getTime()); if (startDateString.length() < 14) { StringBuffer sb = new StringBuffer(Util.ZERO_14); sb.replace((14 - startDateString.length()), 14, startDateString); startDateString = sb.toString(); } String endDateString = Long.toString(enddate.getTime()); if (endDateString.length() < 14) { StringBuffer sb = new StringBuffer(Util.ZERO_14); sb.replace((14 - endDateString.length()), 14, endDateString); endDateString = sb.toString(); } String whereString = " WHERE sellDate BETWEEN '" + startDateString + "' AND '" + endDateString + "' "; // Create SQL statement. String sqlString = "SELECT billZip, SUM(profit) AS PROFITS FROM " + orderInfoTableName + whereString + " GROUP BY billZip ORDER BY PROFITS " + sortOrder + ", billZip"; Util.debug("sqlstring=" + sqlString + "="); sqlStatement = conn.prepareStatement(sqlString); results = sqlStatement.executeQuery(); int i; // Initialize vectors to store data in. Vector[] vecs = new Vector[2]; for (i = 0; i < vecs.length; i++) { vecs[i] = new Vector(); } // Sift thru results. int count = 0; while ((results.next()) && (count < quantity)) { count++; i = 1; vecs[0].addElement(results.getString(i++)); vecs[1].addElement(new Float(results.getFloat(i++))); } // Create report. report = new Report(); report.setReportFieldByRow(Report.ORDER_BILLZIP, vecs[0]); report.setReportFieldByRow(Report.PROFITS, vecs[1]); } catch (NamingException e) { e.printStackTrace(); } catch (SQLException e) { e.printStackTrace(); } finally { // Clean up. try { if (results != null) results.close(); } catch (Exception ignore) { } try { if (sqlStatement != null) sqlStatement.close(); } catch (Exception ignore) { } // Close Connection. try { if (conn != null) conn.close(); } catch (Exception ignore) { } } return report; }
From source file:app.form.person.attribute.AddressDialogHandler.java
public void populateInitialDialogValues(DialogContext dc, int formatType) { if (dc.editingData() || dc.deletingData()) {/*from w w w . java 2s. c om*/ String idParam = (String) dc.getAttribute(PanelEditor.POPULATE_KEY_CONTEXT_ATTRIBUTE); if (idParam == null || idParam.length() == 0) throw new RuntimeException("Address ID was not found in the dialog context."); Query query = dc.getSqlManager().getQuery("personAttribute.get-address-record"); try { QueryResultSet qrs = query.execute(dc, new Object[] { idParam }, false); DialogContextUtils.getInstance().populateFieldValuesFromResultSet(dc, qrs); qrs.close(true); qrs = null; } catch (NamingException e) { e.printStackTrace(); log.error("Failed to populate dialog '" + dc.getDialog().getQualifiedName() + "'.", e); } catch (SQLException e) { e.printStackTrace(); log.error("Failed to populate dialog '" + dc.getDialog().getQualifiedName() + "'.", e); } } }
From source file:app.form.person.attribute.AddressDialogHandler.java
public void addRecord(DialogContext dc, ConnectionContext cc) throws DialogExecuteException { AddressContext ac = new AddressContext(dc); PersonAddressTable personAddressTable = DataAccessLayer.getInstance().getPersonTable().getPersonAddressTable(); PersonAddressTable.Record personAddressRow = personAddressTable.createRecord(); try/*ww w . j a v a2s. c o m*/ { personAddressRow.setRecStatId(new GenericValue(new Integer(RecordStatus.ACTIVE))); personAddressRow.setAddressName(ac.getAddressName()); personAddressRow.setAddressTypeId(ac.getAddressTypeIdState().getValue()); personAddressRow.setMailing(ac.getMailing()); personAddressRow.setParentId(ac.getParentId()); personAddressRow.setLine1(ac.getLine1()); personAddressRow.setLine2(ac.getLine2()); personAddressRow.setCity(ac.getCity()); personAddressRow.setCounty(ac.getCounty()); personAddressRow.setStateId(ac.getState()); personAddressRow.setZip(ac.getZip()); personAddressRow.setCountry(ac.getCountry()); personAddressRow.insert(cc); cc.commitAndClose(); } catch (NamingException e) { e.printStackTrace(); log.error("Failed to add address in dialog '"+ dc.getDialog().getQualifiedName() + "' for person id '" + ac.getParentId() +"'.", e); } catch (SQLException e) { e.printStackTrace(); log.error("Failed to add address in dialog '"+ dc.getDialog().getQualifiedName() + "' for person id '" + ac.getParentId() +"'.", e); } }
From source file:app.form.person.attribute.AddressDialogHandler.java
public void editRecord(DialogContext dc, ConnectionContext cc) throws DialogExecuteException { AddressContext ac = new AddressContext(dc); PersonAddressTable personAddressTable = DataAccessLayer.getInstance().getPersonTable().getPersonAddressTable(); PersonAddressTable.Record personAddressRow = null; try/*from w w w . j a v a2s . com*/ { personAddressRow = personAddressTable.getRecordByPrimaryKey(cc, ac.getSystemIdState().getValue().getTextValue()); personAddressRow.setRecStatId(new GenericValue(new Integer(RecordStatus.ACTIVE))); personAddressRow.setAddressName(ac.getAddressName()); personAddressRow.setAddressTypeId(ac.getAddressTypeIdState().getValue()); personAddressRow.setMailing(ac.getMailing()); personAddressRow.setParentId(ac.getParentId()); personAddressRow.setLine1(ac.getLine1()); personAddressRow.setLine2(ac.getLine2()); personAddressRow.setCity(ac.getCity()); personAddressRow.setCounty(ac.getCounty()); personAddressRow.setStateId(ac.getState()); personAddressRow.setZip(ac.getZip()); personAddressRow.setCountry(ac.getCountry()); personAddressRow.update(cc); cc.commitAndClose(); } catch (NamingException e) { e.printStackTrace(); log.error("Failed to update address in dialog '"+ dc.getDialog().getQualifiedName() + "' for person id '" + ac.getParentId() +"'.", e); } catch (SQLException e) { e.printStackTrace(); log.error("Failed to update address in dialog '"+ dc.getDialog().getQualifiedName() + "' for person id '" + ac.getParentId() +"'.", e); } }