List of usage examples for java.sql SQLException toString
public String toString()
From source file:org.castor.cpa.persistence.sql.keygen.MaxKeyGenerator.java
/** * Generate a new key for the specified table as "MAX(primary_key) + 1". * If there is no records in the table, then the value 1 is returned. * <br/>//from w w w . jav a2 s . co m * {@inheritDoc} */ public Object generateKey(final Connection conn, final String tableName, final String primKeyName) throws PersistenceException { PreparedStatement stmt = null; try { String sql = getQueryExpression(tableName, primKeyName); stmt = conn.prepareStatement(sql); ResultSet rs = stmt.executeQuery(); return _typeHandler.getNextValue(rs); } catch (SQLException ex) { throw new PersistenceException( Messages.format("persist.keyGenSQL", getClass().getName(), ex.toString()), ex); } finally { if (stmt != null) { try { stmt.close(); } catch (SQLException ex) { LOG.warn(Messages.message("persist.stClosingFailed"), ex); } } } }
From source file:com.redip.dao.impl.QualityNonconformitiesDocDAO.java
@Override public String deleteNonconformityDoc(int idQualityNonconformityDoc) { String statusmessage = ""; final String sql = "Delete from qualitynonconformitiesdoc " + " WHERE Idqualitynonconformitiesdoc = '" + idQualityNonconformityDoc + "'"; Logger.log(QualityNonconformitiesImpactDAOImpl.class.getName(), Level.INFO, "Connecting to jdbc/qualityfollowup from deleteNonconformitiesDoc"); Connection connection = this.databaseSpring.connect(); try {/*w w w .j a v a 2 s . c o m*/ PreparedStatement preStat = connection.prepareStatement(sql.toString()); try { int resultSet = preStat.executeUpdate(); try { if (resultSet > 0) { statusmessage = "[Success] IDNCI:" + idQualityNonconformityDoc + " has successfully been deleted"; } else { statusmessage = "[Error] IDNCI:" + idQualityNonconformityDoc + " has not been deleted"; } } catch (Exception exception) { Logger.log(QualityNonconformitiesDAOImpl.class.getName(), Level.ERROR, exception.toString()); } } catch (SQLException exception) { Logger.log(QualityNonconformitiesDAOImpl.class.getName(), Level.ERROR, exception.toString()); } finally { preStat.close(); } } catch (SQLException exception) { Logger.log(QualityNonconformitiesDAOImpl.class.getName(), Level.ERROR, exception.toString()); } finally { try { if (connection != null) { Logger.log(QualityNonconformitiesImpactDAOImpl.class.getName(), Level.INFO, "Disconnecting to jdbc/qualityfollowup from deleteNonconformitiesImpact"); connection.close(); } } catch (SQLException e) { Logger.log(QualityNonconformitiesDAOImpl.class.getName(), Level.WARN, e.toString()); } } return statusmessage; }
From source file:com.cloudera.sqoop.manager.CubridManagerImportTest.java
@After public void tearDown() { super.tearDown(); try {/*from w w w .ja v a2 s . co m*/ manager.close(); } catch (SQLException sqlE) { LOG.error("Got SQLException: " + sqlE.toString()); fail("Got SQLException: " + sqlE.toString()); } }
From source file:com.boldust.general.LocalDAO.java
public synchronized int query(String expression) throws LocalDAOException { //pstmt = null; int k = cter.getAndIncrement(); try {//from w w w . jav a 2 s . com chmps.put(k, conn.prepareStatement(expression)); } catch (SQLException sqle) { System.err.print("\nQuery DataBase Preparation Fail! Error = " + sqle.toString()); throw new LocalDAOException("SQL statement preparation in dao.Query:", sqle); } return k; }
From source file:com.boldust.general.LocalDAO.java
public synchronized int update(String expression) throws LocalDAOException { // pstmt = null; int k = cter.getAndIncrement(); try {//from w w w . j a va 2 s . c om chmps.put(k, conn.prepareStatement(expression)); } catch (SQLException sqle) { System.err.print("\nUpdate DataBase Preparation Fail! Error = " + sqle.toString()); throw new LocalDAOException("SQL statement preparation in dao.Update:", sqle); } return k; }
From source file:com.redip.dao.impl.QualityNonconformitiesDocDAO.java
@Override public String addNonconformityDoc(QualityNonconformitiesDoc qualityNonconformityDoc) { String statusmessage = ""; final String sql = "INSERT INTO qualitynonconformitiesdoc ( idqualitynonconformities, " + "linkToDoc) values (?,?)"; Integer idqnc = qualityNonconformityDoc.getIdQualityNonconformities() == null ? 0 : qualityNonconformityDoc.getIdQualityNonconformities(); String linkToDoc = qualityNonconformityDoc.getLinkToDoc() == null ? "" : qualityNonconformityDoc.getLinkToDoc(); Logger.log(QualityNonconformitiesDocDAO.class.getName(), Level.INFO, "Connecting to jdbc/qualityfollowup from addNonconformityDoc"); Connection connection = this.databaseSpring.connect(); try {// ww w . j ava 2 s . c o m PreparedStatement preStat = connection.prepareStatement(sql); try { preStat.setInt(1, idqnc); preStat.setString(2, linkToDoc); int res = preStat.executeUpdate(); try { if (res > 0) { statusmessage = StatusMessage.SUCCESS_NONCONFORMITYCREATED; } else { statusmessage = StatusMessage.ERROR_NONCONFORMITYCREATEDCREATED; } } catch (Exception exception) { Logger.log(QualityNonconformitiesDAOImpl.class.getName(), Level.ERROR, exception.toString()); } } catch (SQLException exception) { Logger.log(QualityNonconformitiesDAOImpl.class.getName(), Level.ERROR, exception.toString()); } finally { preStat.close(); } } catch (SQLException exception) { Logger.log(QualityNonconformitiesDAOImpl.class.getName(), Level.ERROR, exception.toString()); } finally { try { if (connection != null) { Logger.log(QualityNonconformitiesDAOImpl.class.getName(), Level.INFO, "Disconnecting to jdbc/qualityfollowup from addNonconformity"); connection.close(); } } catch (SQLException e) { Logger.log(QualityNonconformitiesDAOImpl.class.getName(), Level.WARN, e.toString()); } } return statusmessage; }
From source file:com.boldust.general.LocalDAO.java
public synchronized void setInt(int parameterIndex, int x, int psIndex) { try {//from w w w . ja va 2s . c o m getPstmt(psIndex).setInt(parameterIndex, x); } catch (SQLException sqle) { System.err.println(" pstmt.setInt(parameterIndex, x) Fail! Error = " + sqle.toString()); } catch (Exception e) { System.err.println("Possibly null pointer in setInt"); } }
From source file:com.cloudera.sqoop.manager.TestSqlManager.java
@Test public void testReadMissingTable() { ResultSet results = null;/*from w w w .j a va 2 s . c om*/ try { String[] colNames = { "*" }; results = manager.readTable(MISSING_TABLE, colNames); assertNull("Expected null resultset from readTable(MISSING_TABLE)", results); } catch (SQLException sqlException) { // we actually expect this. pass. } finally { if (null != results) { try { results.close(); } catch (SQLException sqlE) { fail("SQL Exception in ResultSet.close(): " + sqlE.toString()); } } manager.release(); } }
From source file:com.boldust.general.LocalDAO.java
public synchronized void setObject(int parameterIndex, Object x, int psIndex) { try {//from www. j a v a 2 s .c o m getPstmt(psIndex).setObject(parameterIndex, x); } catch (SQLException sqle) { System.err.println(" pstmt.setObject(parameterIndex, x) Fail! Error = " + sqle.toString()); } }
From source file:com.boldust.general.LocalDAO.java
public synchronized void setDouble(int parameterIndex, double x, int psIndex) { try {/*w w w.j a v a 2s . co m*/ getPstmt(psIndex).setDouble(parameterIndex, x); } catch (SQLException sqle) { System.err.println(" pstmt.setDouble(parameterIndex, x) Fail! Error = " + sqle.toString()); } }