mirror of
https://github.com/alibaba/druid.git
synced 2023-03-04 19:17:16 +00:00
hbase support
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
package com.alibaba.druid.hbase;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.sql.Connection;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.util.Properties;
|
||||
@@ -12,15 +13,17 @@ public class HBaseDriverInsertTest extends TestCase {
|
||||
HBaseDriver driver = new HBaseDriver();
|
||||
Connection conn = driver.connect("jdbc:druid-hbase:10.20.153.63", new Properties());
|
||||
|
||||
PreparedStatement stmt = conn.prepareStatement("INSERT INTO test_user (id, name, gender) VALUES (?, ?, ?)");
|
||||
stmt.setInt(1, 33);
|
||||
stmt.setString(2, "ljw");
|
||||
stmt.setString(3, "M");
|
||||
|
||||
for (int i = 0; i < 10; ++i) {
|
||||
PreparedStatement stmt = conn.prepareStatement("INSERT INTO test_user (id, name, gender, salary) VALUES (?, ?, ?, ?)");
|
||||
stmt.setInt(1, i);
|
||||
stmt.setString(2, "user-" + i);
|
||||
stmt.setString(3, "M");
|
||||
stmt.setBigDecimal(4, new BigDecimal((i + 1) * 1000));
|
||||
|
||||
stmt.execute();
|
||||
stmt.execute();
|
||||
|
||||
stmt.close();
|
||||
stmt.close();
|
||||
}
|
||||
|
||||
conn.close();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user