1、在数据库上创建sbspaces
2、在数据库上创建包含json类型的表,json列用来存储大量的文本
3、JAVA测试代码样例如下
import java.sql.*;
public class TestJson {
private static String URL_STRING =
"jdbc:gbasedbt-sqli://192.168.69.219:9022/ttdb:" +
"GBASEDBTSERVER=gbase01;NEWCODESET=GB18030,GB18030-2000,5488;" +
"DB_LOCALE=zh_cn.GB18030-2000;CLIENT_LOCALE=zh_cn.GB18030-2000;";
private static String USER = "gbasedbt";
private static String PASSWORD = "XXXX";
public static String lpad(String str,int num,String pad){
String n_str=str;
if(str==null)
n_str= " ";
for(int i=str.length();i <num;i++){
n_str=pad+n_str;
}
return n_str;
}
public static void main( String[] args)
throws SQLException, ClassNotFoundException {
Class.forName( "com.gbasedbt.jdbc.IfxDriver" );
try {
Connection conn = DriverManager.getConnection(URL_STRING, USER, PASSWORD);
Statement stmt0 = conn.createStatement();
stmt0.execute("drop table if exists tabjson");
stmt0.executeUpdate( "create table tabjson ( col1 int, col2 json)" );
String sqls="insert into tabjson values(?, ?)";
PreparedStatement stmt1 = conn.prepareStatement(sqls);
stmt1.setInt(1, 123034);
String jsoninfo = lpad("ABCD", 6400, "吃瓜群众");
stmt1.setObject(2, jsoninfo);
stmt1.executeUpdate();
stmt0.close();
stmt1.close();
conn.close();
} catch( Exception e) {
e.printStackTrace();
}
return;
}
}
备注:
操作text/byte类型和操作基本上这这个一样,不用赘述。