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
HBase >> mail # user >> HBase bulk importtsv - Bad lines error


Copy link to this message
-
Re: HBase bulk importtsv - Bad lines error
Hi,

Can you also share how exactly you invoke the import-tsv command?

On Tue, Jun 19, 2012 at 9:02 PM, AnandaVelMurugan Chandra Mohan
<[EMAIL PROTECTED]> wrote:
> Hi,
>
> I am trying to use importtsv map-reduce job to load data into HBase.
>
> I am creating TSV file after fetching data from MySQL DB using the
> following java code.
>
> But Hadoop complains that my TSV file has bad lines and no data is being
> imported into HBase
>
> Am i doing something wrong here? Any inputs would be greatly appreciated.
>
> public class MySQLTest {
>
>    public static void main(String[] args) {
>
>        String jdbcURL = "jdbc:mysql://199.65.32.78/Report";
>        String dbClass = "org.gjt.mm.mysql.Driver";
>        String user="user";
>        String passwd="password^";
>        String query = "Select
> reports.report_ID,reports.report_path,reports.report_time FROM reports";
>        try {
>            File f = new File("./XYZ.tsv");
>            f.createNewFile();
>            FileOutputStream fos = new FileOutputStream(f);
>            Class.forName(dbClass);
>            Connection con = (Connection) DriverManager.getConnection
> (jdbcURL,user,passwd);
>            java.sql.Statement stmt = con.createStatement();
>            java.sql.ResultSet rs = stmt.executeQuery(query);
>            while (rs.next()) {
>
>                //report id
>                fos.write(String.valueOf(rs.getInt(1)).getBytes());
>                fos.write("\t".getBytes());
>                System.out.println(rs.getInt(1));
>
>                //report path
>                fos.write(rs.getString(2).getBytes());
>                fos.write("\t".getBytes());
>                System.out.println(rs.getString(2));
>
>                //report time
>                fos.write(rs.getString(3).getBytes());
>                fos.write("\t".getBytes());
>                System.out.println(rs.getString(3));
>                fos.write("\n".getBytes());
>
>                } //end while
>            fos.close();
>            con.close();
>        } catch (ClassNotFoundException e) {
>            // TODO Auto-generated catch block
>            e.printStackTrace();
>        } catch (SQLException e) {
>            // TODO Auto-generated catch block
>            e.printStackTrace();
>        } catch (IOException e) {
>            // TODO Auto-generated catch block
>            e.printStackTrace();
>        }
>
>    }
> }
> --
> Regards,
> Anand

--
Harsh J
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