List of usage examples for java.sql SQLException SQLException
public SQLException(Throwable cause)
SQLException
object with a given cause
. From source file:com.pactera.edg.am.metamanager.extractor.dao.helper.CreateMetadataHelper.java
public Object doInPreparedStatement(PreparedStatement ps) throws SQLException { // ?//from w w w . j ava 2 s . c om Map<String, String> mAttrs = metaModel.getMAttrs(); boolean hasChildMetaModel = metaModel.isHasChildMetaModel(); // ??? List<AbstractMetadata> metadatas = metaModel.getMetadatas(); int size = metadatas.size(); String code = ""; String metaModelCode = ""; MMMetadata parentMetadata = null; String logMsg = ""; try { for (int i = 0; i < size; i++) { MMMetadata metadata = (MMMetadata) metadatas.get(i); if (metadata.isHasExist()) { // ??,?? continue; } parentMetadata = metadata.getParentMetadata(); if (parentMetadata == null) { String error = new StringBuilder("?:").append(metadata.getCode()) .append(" ,??!!").toString(); log.error(error); throw new SQLException(error); } String metadataNamespace = genNamespace(parentMetadata, metadata.getId(), hasChildMetaModel); // ?ID ps.setString(1, metadata.getId()); code = metadata.getCode(); // ??? ps.setString(2, code); // ??? ps.setString(3, (metadata.getName() == null || metadata.getName().equals("")) ? code : metadata.getName()); // ID metaModelCode = metaModel.getCode(); ps.setString(4, metaModelCode); // namespaceID ps.setString(5, metadataNamespace); ps.setString(6, parentMetadata.getId()); // START_TIME: ps.setLong(7, this.getGlobalTime()); int index = setAttrs(ps, metadata, mAttrs); setPs(ps, metadata, index + 7); if (log.isDebugEnabled()) { log.debug(new StringBuilder().append(":parent_id:").append(parentMetadata.getId()) .append(",parent_code:").append(parentMetadata.getCode()).append(",instance_code:") .append(code).append(",classifier_id:").append(metaModelCode).toString()); } ps.addBatch(); // ?? ps.clearParameters(); if (++super.count % super.batchSize == 0) { ps.executeBatch(); ps.clearBatch(); } } if (super.count % super.batchSize != 0) { ps.executeBatch(); ps.clearBatch(); } } catch (SQLException e) { logMsg = new StringBuilder().append("?,?:parent_id:") .append(parentMetadata.getId()).append(",parent_code:").append(parentMetadata.getCode()) .append(",instance_code:").append(code).append(",classifier_id:").append(metaModelCode) .append(" ?:").append(e.getLocalizedMessage()).toString(); log.error(logMsg); AdapterExtractorContext.addExtractorLog(ExtractorLogLevel.ERROR, logMsg); throw e; } return null; // test for callback // throw new SQLException(); }
From source file:com.aoindustries.website.clientarea.accounting.ConfigureAutomaticBillingCompletedAction.java
@Override public ActionForward executePermissionGranted(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response, SiteSettings siteSettings, Locale locale, Skin skin, AOServConnector aoConn) throws Exception { // Business must be selected and accessible String accounting = request.getParameter("accounting"); if (GenericValidator.isBlankOrNull(accounting)) { return mapping.findForward("credit-card-manager"); }/*from w w w .j a v a 2 s . com*/ Business business = aoConn.getBusinesses().get(AccountingCode.valueOf(accounting)); if (business == null) { return mapping.findForward("credit-card-manager"); } // CreditCard must be selected or "", and part of the business String pkey = request.getParameter("pkey"); if (pkey == null) { return mapping.findForward("credit-card-manager"); } CreditCard creditCard; if (pkey.length() == 0) { creditCard = null; } else { creditCard = aoConn.getCreditCards().get(Integer.parseInt(pkey)); if (creditCard == null) return mapping.findForward("credit-card-manager"); if (!creditCard.getBusiness().equals(business)) throw new SQLException("Requested business and CreditCard business do not match: " + creditCard.getBusiness().getAccounting() + "!=" + business.getAccounting()); } business.setUseMonthlyCreditCard(creditCard); // Store request attributes request.setAttribute("business", business); request.setAttribute("creditCard", creditCard); return mapping.findForward("success"); }
From source file:org.zenoss.zep.dao.impl.EventSummaryRowMapper.java
@Override public EventSummary mapRow(ResultSet rs, int rowNum) throws SQLException { final EventSummary.Builder summaryBuilder = EventSummary.newBuilder(); summaryBuilder.addOccurrence(mapEvent(rs)); summaryBuilder.setUuid(uuidConverter.fromDatabaseType(rs, COLUMN_UUID)); summaryBuilder.setStatus(EventStatus.valueOf(rs.getInt(COLUMN_STATUS_ID))); summaryBuilder.setFirstSeenTime(timestampConverter.fromDatabaseType(rs, COLUMN_FIRST_SEEN)); summaryBuilder.setStatusChangeTime(timestampConverter.fromDatabaseType(rs, COLUMN_STATUS_CHANGE)); summaryBuilder.setLastSeenTime(timestampConverter.fromDatabaseType(rs, COLUMN_LAST_SEEN)); summaryBuilder.setUpdateTime(timestampConverter.fromDatabaseType(rs, COLUMN_UPDATE_TIME)); summaryBuilder.setCount(rs.getInt(COLUMN_EVENT_COUNT)); String currentUserUuid = uuidConverter.fromDatabaseType(rs, COLUMN_CURRENT_USER_UUID); if (currentUserUuid != null) { summaryBuilder.setCurrentUserUuid(currentUserUuid); }/*w ww. ja v a 2 s . c o m*/ String currentUserName = rs.getString(COLUMN_CURRENT_USER_NAME); if (currentUserName != null) { summaryBuilder.setCurrentUserName(currentUserName); } String clearedByEventUuid = uuidConverter.fromDatabaseType(rs, COLUMN_CLEARED_BY_EVENT_UUID); if (clearedByEventUuid != null) { summaryBuilder.setClearedByEventUuid(clearedByEventUuid); } String notesJson = rs.getString(COLUMN_NOTES_JSON); if (notesJson != null) { try { List<EventNote> notes = JsonFormat.mergeAllDelimitedFrom("[" + notesJson + "]", EventNote.getDefaultInstance()); summaryBuilder.addAllNotes(notes); } catch (IOException e) { throw new SQLException(e); } } String auditJson = rs.getString(COLUMN_AUDIT_JSON); if (auditJson != null) { try { List<EventAuditLog> auditLog = JsonFormat.mergeAllDelimitedFrom("[" + auditJson + "]", EventAuditLog.getDefaultInstance()); summaryBuilder.addAllAuditLog(auditLog); } catch (IOException e) { throw new SQLException(e); } } return summaryBuilder.build(); }
From source file:com.wso2telco.proxy.util.DBUtils.java
private static Connection getConnection() throws SQLException, NamingException { initializeDatasource();//from w w w . j a v a 2s.co m if (dataSource != null) { return dataSource.getConnection(); } throw new SQLException("Sessions Datasource not initialized properly"); }
From source file:org.bytesoft.bytejta.supports.jdbc.LocalXADataSource.java
public Connection getConnection() throws SQLException { TransactionXid transactionXid = null; try {// w ww .j a va2s . c o m Transaction transaction = (Transaction) this.transactionManager.getTransaction(); if (transaction == null) { return this.dataSource.getConnection(); } transaction.registerTransactionListener(this); transactionXid = transaction.getTransactionContext().getXid(); LocalXAResourceDescriptor descriptor = null; LocalXAResource localRes = null; LogicalConnection connection = this.connections.get(transactionXid); if (connection == null) { LocalXAConnection xacon = this.getXAConnection(); connection = xacon.getConnection(); descriptor = xacon.getXAResource(); localRes = (LocalXAResource) descriptor.getDelegate(); this.connections.put(transactionXid, connection); } if (descriptor != null) { transaction.enlistResource(descriptor); connection.setCloseImmediately(localRes.hasParticipatedTx() == false); } return connection; } catch (SystemException ex) { throw new SQLException(ex); } catch (RollbackException ex) { throw new SQLException(ex); } catch (RuntimeException ex) { throw new SQLException(ex); } }
From source file:com.aliyun.odps.jdbc.OdpsForwardResultSet.java
@Override public void close() throws SQLException { if (isClosed) { return;/* w w w . ja va 2 s . c om*/ } isClosed = true; sessionHandle = null; try { if (reader != null) { reader.close(); } } catch (IOException e) { throw new SQLException(e); } conn.log.fine("the result set has been closed"); }
From source file:com.aoindustries.website.clientarea.accounting.AddCreditCardCompletedAction.java
@Override public ActionForward executePermissionGranted(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response, SiteSettings siteSettings, Locale locale, Skin skin, AOServConnector aoConn) throws Exception { AddCreditCardForm addCreditCardForm = (AddCreditCardForm) form; String accounting = addCreditCardForm.getAccounting(); if (GenericValidator.isBlankOrNull(accounting)) { // Redirect back to credit-card-manager it no accounting selected return mapping.findForward("credit-card-manager"); }/*w w w .java 2s. c om*/ // Validation ActionMessages errors = addCreditCardForm.validate(mapping, request); if (errors != null && !errors.isEmpty()) { saveErrors(request, errors); // Init request values before showing input initRequestAttributes(request, getServlet().getServletContext()); return mapping.findForward("input"); } // Get the credit card processor for the root connector of this website AOServConnector rootConn = siteSettings.getRootAOServConnector(); CreditCardProcessor creditCardProcessor = CreditCardProcessorFactory.getCreditCardProcessor(rootConn); if (creditCardProcessor == null) throw new SQLException("Unable to find enabled CreditCardProcessor for root connector"); // Add card if (!creditCardProcessor.canStoreCreditCards()) throw new SQLException("CreditCardProcessor indicates it does not support storing credit cards."); creditCardProcessor.storeCreditCard( new AOServConnectorPrincipal(rootConn, aoConn.getThisBusinessAdministrator().getUsername().getUsername().toString()), new BusinessGroup(aoConn.getBusinesses().get(AccountingCode.valueOf(accounting)), accounting), new CreditCard(null, // persistenceUniqueId null, // principalName null, // groupName null, // providerId null, // providerUniqueId addCreditCardForm.getCardNumber(), null, // maskedCardNumber Byte.parseByte(addCreditCardForm.getExpirationMonth()), Short.parseShort(addCreditCardForm.getExpirationYear()), addCreditCardForm.getCardCode(), addCreditCardForm.getFirstName(), addCreditCardForm.getLastName(), addCreditCardForm.getCompanyName(), null, null, null, null, null, addCreditCardForm.getStreetAddress1(), addCreditCardForm.getStreetAddress2(), addCreditCardForm.getCity(), addCreditCardForm.getState(), addCreditCardForm.getPostalCode(), addCreditCardForm.getCountryCode(), addCreditCardForm.getDescription())); request.setAttribute("cardNumber", CreditCard.maskCreditCardNumber(addCreditCardForm.getCardNumber())); return mapping.findForward("success"); }
From source file:com.taobao.adfs.database.tdhsocket.client.util.ConvertUtil.java
public static float getFloatFromString(String stringVal) throws SQLException { if (StringUtils.isBlank(stringVal)) { return 0; }/*from ww w . j ava 2 s .c o m*/ try { return Float.parseFloat(stringVal); } catch (NumberFormatException e) { throw new SQLException("Parse integer error:" + stringVal); } }
From source file:org.apache.solr.client.solrj.io.sql.DriverImpl.java
protected URI processUrl(String url) throws SQLException { URI uri;/*w w w. java 2 s .com*/ try { uri = new URI(url.replaceFirst("jdbc:", "")); } catch (URISyntaxException e) { throw new SQLException(e); } if (uri.getAuthority() == null) { throw new SQLException("The zkHost must not be null"); } return uri; }
From source file:es.upm.fiware.rss.expenditureLimit.server.manager.common.test.FactoryResponseTest.java
/** * /*www . jav a2 s.com*/ */ @Test public void catchNewConnectionJson() throws Exception { UriInfo mockUriInfo = Mockito.mock(UriInfo.class); Mockito.when(mockUriInfo.getBaseUri()).thenReturn(new URI("http://www.test.com/go")); GenericJDBCException exception = new GenericJDBCException("sql", new SQLException("reason")); Response bean = FactoryResponse.catchNewConnectionJson(mockUriInfo, exception, "message", "resource"); Assert.assertTrue(true); }