SOLR-1245 DIH eats up SQL exception

git-svn-id: https://svn.apache.org/repos/asf/lucene/solr/trunk@788252 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Noble Paul 2009-06-25 04:51:11 +00:00
parent e340bce86d
commit 57a2a11ac8
1 changed files with 6 additions and 3 deletions

View File

@ -17,6 +17,8 @@
package org.apache.solr.handler.dataimport; package org.apache.solr.handler.dataimport;
import org.apache.solr.common.SolrException; import org.apache.solr.common.SolrException;
import static org.apache.solr.handler.dataimport.DataImportHandlerException.wrapAndThrow;
import static org.apache.solr.handler.dataimport.DataImportHandlerException.SEVERE;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
@ -101,7 +103,7 @@ public class JdbcDataSource extends
final String driver = initProps.getProperty(DRIVER); final String driver = initProps.getProperty(DRIVER);
if (url == null && jndiName == null) if (url == null && jndiName == null)
throw new DataImportHandlerException(DataImportHandlerException.SEVERE, throw new DataImportHandlerException(SEVERE,
"JDBC URL or JNDI name has to be specified"); "JDBC URL or JNDI name has to be specified");
if (driver != null) { if (driver != null) {
@ -146,7 +148,7 @@ public class JdbcDataSource extends
c = dataSource.getConnection(user, pass); c = dataSource.getConnection(user, pass);
} }
} else { } else {
throw new DataImportHandlerException(DataImportHandlerException.SEVERE, throw new DataImportHandlerException(SEVERE,
"the jndi name : '"+jndiName +"' is not a valid javax.sql.DataSource"); "the jndi name : '"+jndiName +"' is not a valid javax.sql.DataSource");
} }
} }
@ -245,7 +247,7 @@ public class JdbcDataSource extends
+ (System.currentTimeMillis() - start)); + (System.currentTimeMillis() - start));
colNames = readFieldNames(resultSet.getMetaData()); colNames = readFieldNames(resultSet.getMetaData());
} catch (Exception e) { } catch (Exception e) {
throw new DataImportHandlerException(DataImportHandlerException.SEVERE, throw new DataImportHandlerException(SEVERE,
"Unable to execute query: " + query, e); "Unable to execute query: " + query, e);
} }
if (resultSet == null) { if (resultSet == null) {
@ -332,6 +334,7 @@ public class JdbcDataSource extends
} catch (SQLException e) { } catch (SQLException e) {
logError("Error reading data ", e); logError("Error reading data ", e);
close(); close();
wrapAndThrow(SEVERE,e);
return false; return false;
} }
} }