HTable table = new HTable(configuration, "riapguh");
//插入数据
System.out.println("add riapguh data");
List<Put> putuser = new ArrayList<Put>();
Put user1 = new Put(new String("用户A").getBytes());
//写入用户员信息
user1.add(new String("user").getBytes(), new String("user_code").getBytes(), new String("u_0001").getBytes());
user1.add(new String("user").getBytes(), new String("user_name").getBytes(), new String("u_用户A").getBytes());
//写入部门信息
user1.add(new String("dpt").getBytes(), new String("dpt_code").getBytes(), new String("d_001").getBytes());
user1.add(new String("dpt").getBytes(), new String("dpt_name").getBytes(), new String("d_部门A").getBytes());
putuser.add(user1);
Put user2 = new Put(new String("用户B").getBytes());
//写入用户员信息
user2.add(new String("user").getBytes(), new String("user_code").getBytes(), new String("u_0002").getBytes());
user2.add(new String("user").getBytes(), new String("user_name").getBytes(), new String("u_用户B").getBytes());
//写入部门信息
user2.add(new String("dpt").getBytes(), new String("dpt_code").getBytes(), new String("d_002").getBytes());
user2.add(new String("dpt").getBytes(), new String("dpt_name").getBytes(), new String("d_部门B").getBytes());
putuser.add(user2);
Put user3 = new Put(new String("用户C").getBytes());
//写入用户员信息
user3.add(new String("user").getBytes(), new String("user_code").getBytes(), new String("u_0003").getBytes());
user3.add(new String("user").getBytes(), new String("user_name").getBytes(), new String("u_用户C").getBytes());
//写入部门信息
user3.add(new String("dpt").getBytes(), new String("dpt_code").getBytes(), new String("d_003").getBytes());
user3.add(new String("dpt").getBytes(), new String("dpt_name").getBytes(), new String("d_部门C").getBytes());
putuser.add(user3);
table.put(putuser);
table.flushCommits();
//更新用户B
Put updateb = new Put(new String("用户B").getBytes());
//写入用户员信息
updateb.add(new String("user").getBytes(), new String("user_code").getBytes(), new String("u_000xsx").getBytes());
updateb.add(new String("user").getBytes(), new String("user_name").getBytes(), new String("u_用户xsx").getBytes());
//写入部门信息
updateb.add(new String("dpt").getBytes(), new String("dpt_code").getBytes(), new String("d_00xsx").getBytes());
updateb.add(new String("dpt").getBytes(), new String("dpt_name").getBytes(), new String("d_部门xsx").getBytes());
table.put(updateb);
table.flushCommits();
//HBaseBasic.selectByRowKey("riapguh");
对于更新里面:这里面我们需要知道是否是我们关系数据库中所理解的更新:我们看下面内容:
java.lang.NoClassDefFoundError: org/apache/commons/logging/LogFactory
at org.apache.hadoop.conf.Configuration.<clinit>(Configuration.java:142)
at www.aboutyun.com.HbaseAddEdtDel.<clinit>(HbaseAddEdtDel.java:18)
Caused by: java.lang.ClassNotFoundException: org.apache.commons.logging.LogFactory
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
... 2 more
Exception in thread "main"
java.lang.NoClassDefFoundError: org/apache/commons/logging/LogFactory
at org.apache.hadoop.conf.Configuration.<clinit>(Configuration.java:142)
at www.aboutyun.com.HbaseAddEdtDel.<clinit>(HbaseAddEdtDel.java:18)
Caused by: java.lang.ClassNotFoundException: org.apache.commons.logging.LogFactory
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
... 2 more
Exception in thread "main"
我用的是log4j-1.2.16.jar包,还是不行,我就是不懂下面这句话是什么意思?14/10/09 10:39:15 WARN client.ZooKeeperSaslClient: SecurityException: java.lang.SecurityException: 无法定位登录配置 occurred when trying to find JAAS configuration.
14/10/09 10:39:15 INFO client.ZooKeeperSaslClient: Client will not SASL-authenticate because the default JAAS configuration section 'Client' could not be found. If you are not using SASL, you may ignore this. On the other hand, if you expected SASL to work, please fix your JAAS configuration.