Home | About | Sematext search-lucene.com search-hadoop.com
NEW: Monitor These Apps!
elasticsearch, apache solr, apache hbase, hadoop, redis, casssandra, amazon cloudwatch, mysql, memcached, apache kafka, apache zookeeper, apache storm, ubuntu, centOS, red hat, debian, puppet labs, java, senseiDB
 Search Hadoop and all its subprojects:

Switch to Threaded View
Sqoop >> mail # user >> sqoop2 export from hdfs into mysql - hitting sqlexception - parameter index out of range


Copy link to this message
-
sqoop2 export from hdfs into mysql - hitting sqlexception - parameter index out of range
Hi
I'm trying to export a csv from hdfs into mysql using sqoop2 in hue as
demonstrated here (view snapshot).
http://gethue.com/hadoop-tutorials-series-ii-8-how-to-transfer-data/

input data sample-  cat /user/root/s2t4/part-m-00000
1,'nick miller',68,'green',717.12,13809
2,'ulysses white',48,'green',840.06,19451
3,'holly garcia',18,'democrat',128.2,8750
4,'victor thompson',61,'independent',721.6,20462

This is my* table schema* -
create table voterimport (
rownum int(11) default NULL,
name varchar(50) default NULL,
age tinyint(4) default NULL,
registration varchar(15) default NULL,
contributions float default NULL,
voterzone smallint(6) default NULL);
But I'm hitting this sqlexception. Which parameters is it talking about?

Caused by: org.apache.sqoop.common.SqoopException:
GENERIC_JDBC_CONNECTOR_0002:Unable to execute the SQL statement at
org.apache.sqoop.connector.jdbc.GenericJdbcExecutor.addBatch(GenericJdbcExecutor.java:177)
at org.apache.sqoop.connector.jdbc.GenericJdbcExportLoader.load(GenericJdbcExportLoader.java:50)
at org.apache.sqoop.connector.jdbc.GenericJdbcExportLoader.load(GenericJdbcExportLoader.java:25)
at org.apache.sqoop.job.mr.SqoopOutputFormatLoadExecutor$ConsumerThread.run(SqoopOutputFormatLoadExecutor.java:228)
... 6 moreCaused by: java.sql.SQLException: Parameter index out of
range (2 > number of parameters, which is 1).
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:910)
at com.mysql.jdbc.PreparedStatement.setInternal(PreparedStatement.java:2796)
at com.mysql.jdbc.PreparedStatement.setString(PreparedStatement.java:3627)
at com.mysql.jdbc.PreparedStatement.setObject(PreparedStatement.java:3029)
at org.apache.sqoop.connector.jdbc.GenericJdbcExecutor.addBatch(GenericJdbcExecutor.java:173)
This is from GenericJdbcExecutor.java - sqoop2 code
  public void addBatch(Object[] array) {
    try {
      for (int i=0; i<array.length; i++) {
        preparedStatement.setObject(i+1, array[i]);
      }
*      preparedStatement.addBatch();*
    } catch (SQLException e) {
      throw new SqoopException(
          GenericJdbcConnectorError.GENERIC_JDBC_CONNECTOR_0002, e);
    }
  }

How do I get around this issue?
Thanks,
Suhas.

  
NEW: Monitor These Apps!
elasticsearch, apache solr, apache hbase, hadoop, redis, casssandra, amazon cloudwatch, mysql, memcached, apache kafka, apache zookeeper, apache storm, ubuntu, centOS, red hat, debian, puppet labs, java, senseiDB