/** * Return the wrapped SQLException. */ public SQLException getSQLException() { return (SQLException) getCause(); }
/** * Return the wrapped SQLException. */ public SQLException getSQLException() { return (SQLException) getCause(); }
/** * Return the wrapped SQLException. */ public SQLException getSQLException() { return (SQLException) getCause(); }
/*** * In case of fall-back to legacy stored procedure names, the errors caused by calling new non-existing procedures should be ignored. * The exceptions in this case are similar to :'com.sap.db.jdbc.exceptions.JDBCDriverException: SAP DBTech JDBC: [328]: invalid name of * function or procedure: USER_SECURESTORE_INSERT', and are not in current dependency tree. */ private void throwIfShouldNotIgnore(BadSqlGrammarException e, String procedureName) { String errorMessage = e.getCause() .getMessage(); if (errorMessage.contains(procedureName)) { return; } throw e; } }
@Override public boolean tableExists(ExtendedJdbcTemplate ejt, String tableName) { try { ejt.execute("SELECT COUNT(*) FROM " + tableName); } catch (BadSqlGrammarException e) { if (e.getCause() instanceof PSQLException) { SQLException se = (SQLException) e.getCause(); // This state means a missing table. return !"42P01".equals(se.getSQLState()); } throw e; } return true; }
@Override public String testSqlGrammar( String sql ) { String viewName = SqlView.PREFIX_VIEWNAME + System.currentTimeMillis(); sql = "CREATE VIEW " + viewName + " AS " + sql; log.debug( "Test view SQL: " + sql ); try { jdbcTemplate.execute( sql ); jdbcTemplate.execute( "DROP VIEW IF EXISTS " + viewName ); } catch ( BadSqlGrammarException ex ) { return ex.getCause().getMessage(); } catch ( UncategorizedSQLException ex ) { return ex.getCause().getMessage(); } return null; }
@Override public String createViewTable( SqlView sqlView ) { dropViewTable( sqlView ); final String sql = TYPE_CREATE_PREFIX_MAP.get( sqlView.getType() ) + statementBuilder.columnQuote( sqlView.getViewName() ) + " AS " + sqlView.getSqlQuery(); log.debug( "Create view SQL: " + sql ); try { jdbcTemplate.execute( sql ); return null; } catch ( BadSqlGrammarException ex ) { return ex.getCause().getMessage(); } }