返回首页

gbase数据、南大通用产品文档:GBase8a

更新日期:2024年09月11日

table_distribution
表的当前distribution 信息
表 5-93 具体信息如下:
index_name
dbName.tbName 组成
dbName
数据库名
tbName
表名
isReplicate
是否为复制表
hash_column
hash 列名
lmt_storage_size
表容量上限
table_storage_size
当前表容量

GBase UP 产品手册 5 数据库管理指南
文档版本04(2021-04-21) 南大通用数据技术股份有限公司 328
is_nocopies
是否为nocopy 表
data_distribution_id
表的distribution_id

bigintcvint2() 函数将 int2 类型数值转换为 BIGINT 类型数值。

GBase 8s ESQL/C 编程指南
南大通用数据技术股份有限公司
- 606 -

语法
mint bigintcvint2(int2v, bigintp)
const int2 int2v
bigint *bigintp
int2v
要转换为 bigint 值的 int2 值。
bigintp
指向包含转换的结果的 bigint 变量的指针。

返回代码
0
转换成功。
<0
转换失败。

该示例主要内容为在Tomcat 服务器上配置GBase 数据源。对Tomcat 本身
的安装以及Web 工程的创建不做讨论。
本示例基本信息如下:
Tomcat: tomcat-5.5.30
GBase JDBC: GBase JDBC 驱动

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

- 159 -
JDK: JDK1.6
Tomcat 安装路径假设为: $TOMCAT_HOME
步骤如下:
1) 将GBase JDBC 驱动包GBase JDBC 驱动拷贝至tomcat 目录
$TOMCAT_HOME\common\lib 。
2) 通过在$TOMCAT_HOME\conf\Catalina\localhost 目录下增加声明资源
文件,
该文件以Web 应用名称为名
(例:GBaseapp.xml)

配置JNDI
DataSource,
内容部分如下:


name="jdbc/GBaseDB"
type="javax.sql.DataSource"
password="somepassword"
driverClassName="com.gbase.jdbc.Driver"
maxIdle="2"
maxWait="50"
username="user"
url="jdbc:gbase://localhost:5258/test"
maxActive="4"/>

3) 修改Web 应用目录 WebRoot\WEB-INF 下的web.xml,添加如下内容:


GBase 8a 程序员手册JDBC 篇


- 160 -

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

gbasetomcatServlet

gbasetomcat.gbasetomcatServlet




gbasetomcatServlet
/gbasetomcatServlet


DB Connection
jdbc/GBaseDB
javax.sql.DataSource
Container

4) 创建Servlet 测试连接池,代码如下:
package gbasetomcat;

import java.io.IOException;
import java.io.PrintWriter;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.Statement;

import javax.naming.Context;
import javax.naming.InitialContext;
import javax.servlet.ServletException;

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

- 161 -
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.sql.DataSource;

public class gbasetomcatServlet extends HttpServlet {

public gbasetomcatServlet() {
super();
}
public void destroy() {
super.destroy();
}

public void doGet(HttpServletRequest request,
HttpServletResponse response)
throws ServletException, IOException {

response.setContentType("text/html");
PrintWriter out = response.getWriter();

Connection conn = null;
Statement stmt = null;
ResultSet rs = null;
try {
System.out.println("come");
Context initCtx = new InitialContext();
//获得连接池
DataSource ds =
(DataSource)initCtx.lookup("java:comp/env/jdbc/GBase
DB");
//创建连接
conn = ds.getConnection();
if (conn != null){
out.println("The Gbase connection is ok!!");
System.out.println("ok");

GBase 8a 程序员手册JDBC 篇


- 162 -

南大通用数据技术股份有限公司
}else{
out.println("The Gbase connection occur error");
System.out.println("error");
}
//使用连接创建Statement 对象执行SQL 语句
Statement st = conn.createStatement();
ResultSet rs1= st.executeQuery("select cust_name from
customers where cust_id=1");
//获得执行结果,输出结果
while(rs1.next()){
out.println(rs1.getString(1));
System.out.println(rs1.getString(1));
}
}catch(Exception e){
System.out.println("Exception"+e);
}
}

public void doPost(HttpServletRequest request,
HttpServletResponse response)
throws ServletException, IOException {
this.doGet(request, response);
}

public void init() throws ServletException {
}
}
启动Tomcat 服务器,通过
http://localhost:8080/GbaseTomcat/gbasetomcatServlet 访问,
如果输出结
果如下,说明GBase 连接池配置成功。结果:
The Gbase connection is ok!! GBase 8a