hbase-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From neuron005 <neuron...@gmail.com>
Subject Trouble with Boolean,integer and timestamp
Date Wed, 21 Dec 2011 13:52:42 GMT

Hiii there
I am new to hbase and trying to explore it. I am trying to store some values
to hbase using my java program. Though I can easily store string values and
retrieve them but I am having trouble with Boolean int and timestamp.
Boolean --- whatever number I save between 0 to 9 it results in true

int -- does not let me store a number less than 3 digits and if i store a
number of 4 or 5 digits it results in different value

timestamp: How can I get timestamp from hbase for a particular column so
that I can apply toString() method on it to get in format yyyy:mm:dd
Here is my sample program of java with which I am trying
--------------------------------Please add necessary jars to
import java.sql.*;
import java.util.Date;
public class test
public static void main(String args[])
Connection con=null;
Statement stmt = null;
		con = DriverManager.getConnection("jdbc:hbql");
    stmt.execute("CREATE TABLE Activity (f1()) IF NOT

    stmt.execute("CREATE TEMP MAPPING scho8 FOR TABLE Activity"
                 + "("
                 + "keyval key, "
                 + "f1 ("
                 + "User string alias User, "
                 + " date DATE alias date, "
                + " count INTEGER alias count, "
                + " flag boolean alias flag "
                 + ") "
                 + ")");
    ResultSet rs = stmt.executeQuery("select * from scho8");
    System.out.println("hii there");
    while (rs.next()) {
      	System.out.println("hii there you");
        String user=rs.getString("User");
        Date feedDate=rs.getDate("date");
    	Timestamp timestamp=rs.getTimestamp("date");
    	int comment = rs.getInt("count");
    	boolean flag=rs.getBoolean("flag");
    	System.out.println("user is : "+ user);
    	System.out.print("feed Date is :"+feedDate);
        System.out.println("Timestamp received is"+timestamp);
        System.out.println("Comment count is: " + comment);
        System.out.println("Flag is: "+flag);
        System.out.print("feed Date is :"+timestamp.toString());
	}catch(Exception e)

View this message in context: http://old.nabble.com/Trouble-with-Boolean%2Cinteger-and-timestamp-tp33016853p33016853.html
Sent from the HBase User mailing list archive at Nabble.com.

View raw message