返回首页

gbase数据、南大通用产品文档:GBase8s访问智能大对象

更新日期:2024年09月11日

本部分描述如何通过使用标准 ODBC API,
或通过使用 ifx_lo 函数,
来选择、
打开、
删除、
修改和关闭智能大对象。

概述
全文检索(FULL TEXT SEARCH)技术就是将各种文章或信息中所有的文字序列
都作为检索对象,找出包含有待索词汇的文章或对象。
GBase 8a MPP Cluster 数据库支持全文检索,
默认采用全单字索引方式,
支持几乎
所有的语种,
并且可以保证100%的查询召回率。结合GBase 8a MPP Cluster 独特
的列存储,压缩和智能索引技术,适合面向海量数据的检索查询应用。

本示例实现了使用Statement.getGeneratedKeys()获取AUTO_INCREMENT
列的值。
示例如下:
package com.gbase.jdbc.simple;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;

public class SampleGetGeneratedKeys {

public static void main(String[] args) {


try {



(new SampleGetGeneratedKeys()).test();


} catch (Exception ex) {



}

}


public void test() throws Exception {


Connection conn = null;


try {



Class.forName("com.gbase.jdbc.Driver").newInstance();



conn = DriverManager





.getConnection("jdbc:gbase://192.168.5.210:5258/test?user=root&p
assword=");


GBase 8a 程序员手册JDBC 篇


- 146 -

南大通用数据技术股份有限公司



Statement stmt = null;



ResultSet rs = null;



try {




// 创建Statement 对象




stmt = conn.createStatement(






java.sql.ResultSet.TYPE_FORWARD_ONLY,






java.sql.ResultSet.CONCUR_UPDATABLE);





// 创建表




stmt.executeUpdate("DROP
TABLE
IF
EXISTS
autoIncTutorial");




stmt.executeUpdate("CREATE TABLE autoIncTutorial ("






+ "priKey INT NOT NULL AUTO_INCREMENT, "






+
"dataField
VARCHAR(64),
PRIMARY
KEY
(priKey))");









// 插入一条数据




stmt.executeUpdate("INSERT
INTO
autoIncTutorial
(dataField) "






+ "values ('Can I Get the Auto Increment
Field?')",






Statement.RETURN_GENERATED_KEYS);









// 使用Statement.getGeneratedKeys()获取自增一字段




int autoIncKeyFromApi = -1;




rs = stmt.getGeneratedKeys();




if (rs.next()) {





autoIncKeyFromApi = rs.getInt(1);




}




rs.close();




rs = null;




System.out.println("Key
returned
from

GBase 8a 程序员手册JDBC 篇
南大通用数据技术股份有限公司

- 147 -
getGeneratedKeys():"






+ autoIncKeyFromApi);



} finally {




if (rs != null) {





try {






rs.close();





} catch (SQLException ex) {






}




}




if (stmt != null) {





try {






stmt.close();





} catch (SQLException ex) {






}




}



}


} catch (SQLException ex) {



// 处理错误



System.out.println("SQLException: " + ex.getMessage());



System.out.println("SQLState: " + ex.getSQLState());



System.out.println("VendorError: " + ex.getErrorCode());


} finally {



conn.close();


}

}
}