hbase-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From AnandaVelMurugan Chandra Mohan <ananthu2...@gmail.com>
Subject HBase bulk importtsv - Bad lines error
Date Tue, 19 Jun 2012 15:32:43 GMT
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

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message