List of usage examples for java.sql SQLException getMessage
public String getMessage()
From source file:net.riezebos.thoth.configuration.persistence.dbs.DDLExecuter.java
protected void executeSingleStmt(Connection conn, Statement stmt, String command) throws DDLException { String actual = command;//from www .j a v a 2 s. c om try { String dialect = applyDialect(command); println(dialect); actual = dialect; if (StringUtils.isNotBlank(dialect)) stmt.execute(dialect); } catch (SQLException e) { LOG.error(e.getMessage(), e); throw new DDLException("Error executing " + actual + "\n" + e.toString()); } }
From source file:com.sfs.dao.FieldMapDAOImpl.java
/** * Load field map.//from www . jav a 2s . c o m * * @param rs the rs * * @return the field map bean * * @throws SQLException the SQL exception */ private FieldMapBean loadFieldMap(final ResultSet rs) throws SQLException { FieldMapBean fieldMap = new FieldMapBean(); // Create field map bean and fill with dataset info. fieldMap.setFieldMapId(rs.getInt("Id")); fieldMap.setMapClass(rs.getString("MapClass")); fieldMap.setMapType(rs.getString("MapType")); fieldMap.setFieldType(rs.getString("FieldType")); fieldMap.setName(rs.getString("FieldName")); fieldMap.setIndex(rs.getInt("FieldNo")); fieldMap.setFieldType(rs.getString("FieldType")); fieldMap.setDescription(rs.getString("Description")); fieldMap.setObjectType(rs.getString("ObjectType")); try { fieldMap.setCreated(rs.getTimestamp("Created")); } catch (SQLException sqe) { dataLogger.info("Could not load Created date: " + sqe.getMessage()); } fieldMap.setCreatedBy(rs.getString("CreatedBy")); try { fieldMap.setModified(rs.getTimestamp("Modified")); } catch (SQLException sqe) { dataLogger.info("Could not load Modified date: " + sqe.getMessage()); } fieldMap.setModifiedBy(rs.getString("ModifiedBy")); if (fieldMap.getCreatedBy() != null && this.userDAO != null) { try { fieldMap.setCreatedByUser(this.userDAO.loadCached(fieldMap.getCreatedBy())); } catch (Exception e) { dataLogger.info( "Could not load CreatedBy UserBean for " + "FieldMapId = " + fieldMap.getFieldMapId()); } } if (fieldMap.getModifiedBy() != null && this.userDAO != null) { try { fieldMap.setModifiedByUser(this.userDAO.loadCached(fieldMap.getModifiedBy())); } catch (Exception e) { dataLogger.info( "Could not load ModifiedBy UserBean for " + "FieldMapId = " + fieldMap.getFieldMapId()); } } return fieldMap; }
From source file:org.cloudfoundry.community.servicebroker.postgresql.service.PostgreSQLServiceInstanceService.java
@Override public CreateServiceInstanceResponse createServiceInstance( CreateServiceInstanceRequest createServiceInstanceRequest) throws ServiceInstanceExistsException, ServiceBrokerException { String serviceInstanceId = createServiceInstanceRequest.getServiceInstanceId(); String serviceId = createServiceInstanceRequest.getServiceDefinitionId(); String planId = createServiceInstanceRequest.getPlanId(); String organizationGuid = createServiceInstanceRequest.getOrganizationGuid(); String spaceGuid = createServiceInstanceRequest.getSpaceGuid(); try {//from ww w .j a va 2 s. c o m dbAdmin.createDatabaseForInstance(serviceInstanceId, serviceId, planId, organizationGuid, spaceGuid); role.createRoleForInstance(serviceInstanceId); } catch (SQLException e) { logger.error("Error while creating service instance '" + serviceInstanceId + "'", e); throw new ServiceBrokerException(e.getMessage()); } ServiceInstance instance = new ServiceInstance(createServiceInstanceRequest); repos.save(instance); return new CreateServiceInstanceResponse(); }
From source file:de.klemp.middleware.controller.Controller.java
/** * This method saves the processes, defined with the GUI, in the database. * // www . j a va 2s . c o m * @param classInput * class of the first component * @param methodInput * method of the first component * @param nameInput * name of the input device * @param classOutput * class of the second component * @param methodOutput * method of the second component * @param data * name of the data, "data fehlt" or "" * @param topic * topic for the message broker */ public static synchronized void setController(String classInput, String methodInput, String nameInput, String classOutput, String methodOutput, String topic, String data) { createDBConnection(); if (classInput != null && methodInput != null && nameInput != null && classOutput != null && methodOutput != null && topic != null && classInput != "" && methodInput != "" && nameInput != "" && classOutput != "" && methodOutput != "" && topic != "") { try { Statement st = conn.createStatement(); PreparedStatement stp = conn.prepareStatement( "insert into \"Controller\"(classInput,methodInput,nameInputDevice,classOutput,methodOutput,topic,data) values (?,?,?,?,?,?,?)"); stp.setString(1, classInput); stp.setString(2, methodInput); stp.setString(3, nameInput); stp.setString(4, classOutput); stp.setString(5, methodOutput); stp.setString(6, topic); stp.setString(7, data); stp.execute(); } catch (SQLException e) { String message = e.getMessage(); if (!message.contains("doppelter Schlsselwert")) { logger.error("SQL Exception", e); } } closeDBConnection(); controllerToList(); } }
From source file:com.cws.us.pws.processors.impl.CareerReferenceImpl.java
/** * @see com.cws.us.pws.processors.interfaces.ICareerReference#getCareerList(CareerRequest) *//* w ww . j a va2 s . c o m*/ @Override public CareerResponse getCareerList(final CareerRequest request) throws CareerRequestException { final String methodName = ICareerReference.CNAME + "#getCareerList(final CareerRequest request) throws CareerRequestException"; if (DEBUG) { DEBUGGER.debug(methodName); } CareerResponse response = new CareerResponse(); try { List<Object[]> careerList = this.dao.getCareerList(request.getLang()); if (DEBUG) { DEBUGGER.debug("careerList: {}", careerList); } if ((careerList != null) && (careerList.size() != 0)) { List<Career> careers = new ArrayList<>(); for (Object[] array : careerList) { Career career = new Career(); career.setJobReqId((String) array[0]); career.setPostDate((Date) array[1]); career.setUnpostDate((Date) array[2]); career.setJobTitle((String) array[3]); career.setJobShortDesc((String) array[4]); career.setJobDescription((String) array[5]); if (DEBUG) { DEBUGGER.debug("Career: {}", career); } careers.add(career); } if (DEBUG) { DEBUGGER.debug("List<careers>: {}", careers); } response.setRequestStatus(CoreServicesStatus.SUCCESS); response.setResponse("Successfully loaded product list."); response.setCareerList(careers); } else { response.setRequestStatus(CoreServicesStatus.FAILURE); response.setResponse("Failed to load available products"); } } catch (SQLException sqx) { ERROR_RECORDER.error(sqx.getMessage(), sqx); throw new CareerRequestException(sqx.getMessage(), sqx); } if (DEBUG) { DEBUGGER.debug("CareerResponse: {}", response); } return response; }
From source file:net.ageto.gyrex.persistence.jdbc.pool.internal.commands.ListPools.java
private void printPool(final PoolDefinition pool) throws BackingStoreException { printf("Pool %s", pool.getPoolId()); printf(StringUtils.EMPTY);/*from ww w. j a va 2 s . co m*/ final Properties driverProperties = pool.getDriverProperties(); if (!driverProperties.isEmpty()) { printf("Driver Properties:"); final SortedSet<String> names = new TreeSet<String>(); final Enumeration<?> propertyNames = driverProperties.propertyNames(); while (propertyNames.hasMoreElements()) { names.add((String) propertyNames.nextElement()); } for (final String key : names) { printf(" %35s: %s", key, StringUtils.trimToEmpty(driverProperties.getProperty(key))); } printf(StringUtils.EMPTY); } printf("Pool Statistics:"); final BoneCPDataSource dataSource = (BoneCPDataSource) PoolActivator.getInstance().getRegistry() .getDataSource(pool.getPoolId()); // test connectivity (this also works around a bug in BoneCP which would result in an NPE below) try { final Connection connection = dataSource.getConnection(); if (connection instanceof ConnectionHandle) { printf(" %35s: %s", "connectionTest", ((ConnectionHandle) connection).isValid(1000) ? "OK" : "NOT OK"); } else { printf(" %35s: %s", "connectionSample", connection.toString()); } connection.close(); } catch (final SQLException e) { printf(" unable to connect to pool: %s", e.getMessage()); } // total number of leased connections printf(" %35s: %d", "totalLeased", dataSource.getTotalLeased()); printf(StringUtils.EMPTY); printf("Effective Pool Config:"); final TreeMap<String, String> poolConfig = readPoolConfig(dataSource); for (final Entry<String, String> entry : poolConfig.entrySet()) { printf(" %35s: %s", entry.getKey(), entry.getValue()); } }
From source file:org.fornax.cartridges.sculptor.framework.util.db.DatabaseExport.java
public List<String> getTables(Connection connection) { List<String> tables = new ArrayList<String>(); PreparedStatement pstmt = null; try {//from w w w .ja v a2s .c o m pstmt = connection.prepareStatement(environmentStrategy.getSqlAllTables()); ResultSet rset = pstmt.executeQuery(); while (rset.next()) { tables.add(rset.getString("table_name")); } } catch (SQLException e) { System.out.println("SQLException: " + e.getMessage()); e.printStackTrace(); } finally { if (pstmt != null) { try { pstmt.close(); } catch (SQLException ignore) { } } } return tables; }
From source file:eionet.cr.dao.readers.NewSourcesReaderWriter.java
/** * @throws ResultSetReaderException/*ww w . j a v a2 s . c o m*/ */ public void finish() throws ResultSetReaderException { try { if (currentBatchSize > 0) { if (LOGGER.isTraceEnabled()) { LOGGER.trace("Inserting " + currentBatchSize + " sources"); } getPreparedStatement().executeBatch(); if (LOGGER.isTraceEnabled()) { LOGGER.trace(sourceCount + " sources inserted in total"); } } } catch (SQLException e) { throw new ResultSetReaderException(e.getMessage(), e); } }
From source file:org.elasticsearch.xpack.qa.sql.jdbc.ErrorsTestCase.java
@Override public void testSelectScoreSubField() throws Exception { index("test", body -> body.field("foo", 1)); try (Connection c = esJdbc()) { SQLException e = expectThrows(SQLException.class, () -> c.prepareStatement("SELECT SCORE().bar FROM test").executeQuery()); assertThat(e.getMessage(), startsWith("line 1:15: extraneous input '.' expecting {<EOF>, ','")); }//from w ww .j a v a2 s . c om }
From source file:com.jaspersoft.jasperserver.util.JasperJdbcContainer.java
public void close() { try {//from w w w . ja va 2 s. co m if (this.resultset != null) this.resultset.close(); if (this.preparedstatement != null) this.preparedstatement.close(); if (this.connection != null) this.connection.close(); } catch (SQLException e) { logger.error(e.getMessage(), e); } }