Return-Path: X-Original-To: apmail-hbase-user-archive@www.apache.org Delivered-To: apmail-hbase-user-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id B23D0C121 for ; Tue, 19 Jun 2012 16:14:05 +0000 (UTC) Received: (qmail 58301 invoked by uid 500); 19 Jun 2012 16:14:04 -0000 Delivered-To: apmail-hbase-user-archive@hbase.apache.org Received: (qmail 58213 invoked by uid 500); 19 Jun 2012 16:14:03 -0000 Mailing-List: contact user-help@hbase.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: user@hbase.apache.org Delivered-To: mailing list user@hbase.apache.org Received: (qmail 58205 invoked by uid 99); 19 Jun 2012 16:14:03 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 19 Jun 2012 16:14:03 +0000 X-ASF-Spam-Status: No, hits=-0.7 required=5.0 tests=FSL_RCVD_USER,RCVD_IN_DNSWL_LOW,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: domain of harsh@cloudera.com designates 209.85.210.41 as permitted sender) Received: from [209.85.210.41] (HELO mail-pz0-f41.google.com) (209.85.210.41) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 19 Jun 2012 16:13:55 +0000 Received: by dakp5 with SMTP id p5so10730390dak.14 for ; Tue, 19 Jun 2012 09:13:34 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :content-type:content-transfer-encoding:x-gm-message-state; bh=h3LOXxO0h0c4An2hsplwFa4PuEsgKfxcBVO7/m6SUVQ=; b=Pq+x9m9iBEI/I87ppRqNjhxEuhU5nMjKP9OFIzNC0ry2OedCAXZoYe9ieSQgI2+2LR xCG1uWPuirVGaNmCQ0z2fMUXG8Fa1xFPYL1aF4A0uYW2UgEAh2n36ZXkfiSFZ/033AgC BOp33T+bgpv3rbcmNn5RDlNXhh0cRUHJPQCGimRS8yeDEwHF488xnJvxR+5NN5kUC7pS qLAoJKRDzkykYFqvW9uPYuaHv81TcHE0AD8/mV+jXaLD2N/3FAI2MYadTnZSjOc7boJ5 0r1J+l5OqDfQ2vEprXWboJ7cDWc8pChIgKjqpetu9oKE0DNIOGpNHsSfqOzdbKERChYp oepA== Received: by 10.68.130.9 with SMTP id oa9mr64833209pbb.95.1340122414287; Tue, 19 Jun 2012 09:13:34 -0700 (PDT) MIME-Version: 1.0 Received: by 10.68.130.201 with HTTP; Tue, 19 Jun 2012 09:13:13 -0700 (PDT) In-Reply-To: References: From: Harsh J Date: Tue, 19 Jun 2012 21:43:13 +0530 Message-ID: Subject: Re: HBase bulk importtsv - Bad lines error To: user@hbase.apache.org Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-Gm-Message-State: ALoCoQk4G8DGSB73j2gft+rdHgPq17L7Oq2JyBZpI5Pzu1pjqdMjm7U8mIxUbvR4Ucjy+XMlO9Se 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 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 { > > =A0 =A0public static void main(String[] args) { > > =A0 =A0 =A0 =A0String jdbcURL =3D "jdbc:mysql://199.65.32.78/Report"; > =A0 =A0 =A0 =A0String dbClass =3D "org.gjt.mm.mysql.Driver"; > =A0 =A0 =A0 =A0String user=3D"user"; > =A0 =A0 =A0 =A0String passwd=3D"password^"; > =A0 =A0 =A0 =A0String query =3D "Select > reports.report_ID,reports.report_path,reports.report_time FROM reports"; > =A0 =A0 =A0 =A0try { > =A0 =A0 =A0 =A0 =A0 =A0File f =3D new File("./XYZ.tsv"); > =A0 =A0 =A0 =A0 =A0 =A0f.createNewFile(); > =A0 =A0 =A0 =A0 =A0 =A0FileOutputStream fos =3D new FileOutputStream(f); > =A0 =A0 =A0 =A0 =A0 =A0Class.forName(dbClass); > =A0 =A0 =A0 =A0 =A0 =A0Connection con =3D (Connection) DriverManager.getC= onnection > (jdbcURL,user,passwd); > =A0 =A0 =A0 =A0 =A0 =A0java.sql.Statement stmt =3D con.createStatement(); > =A0 =A0 =A0 =A0 =A0 =A0java.sql.ResultSet rs =3D stmt.executeQuery(query)= ; > =A0 =A0 =A0 =A0 =A0 =A0while (rs.next()) { > > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0//report id > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0fos.write(String.valueOf(rs.getInt(1)).get= Bytes()); > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0fos.write("\t".getBytes()); > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0System.out.println(rs.getInt(1)); > > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0//report path > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0fos.write(rs.getString(2).getBytes()); > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0fos.write("\t".getBytes()); > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0System.out.println(rs.getString(2)); > > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0//report time > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0fos.write(rs.getString(3).getBytes()); > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0fos.write("\t".getBytes()); > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0System.out.println(rs.getString(3)); > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0fos.write("\n".getBytes()); > > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0} //end while > =A0 =A0 =A0 =A0 =A0 =A0fos.close(); > =A0 =A0 =A0 =A0 =A0 =A0con.close(); > =A0 =A0 =A0 =A0} catch (ClassNotFoundException e) { > =A0 =A0 =A0 =A0 =A0 =A0// TODO Auto-generated catch block > =A0 =A0 =A0 =A0 =A0 =A0e.printStackTrace(); > =A0 =A0 =A0 =A0} catch (SQLException e) { > =A0 =A0 =A0 =A0 =A0 =A0// TODO Auto-generated catch block > =A0 =A0 =A0 =A0 =A0 =A0e.printStackTrace(); > =A0 =A0 =A0 =A0} catch (IOException e) { > =A0 =A0 =A0 =A0 =A0 =A0// TODO Auto-generated catch block > =A0 =A0 =A0 =A0 =A0 =A0e.printStackTrace(); > =A0 =A0 =A0 =A0} > > =A0 =A0} > } > -- > Regards, > Anand --=20 Harsh J