返回首页

gbase数据、南大通用产品文档:GBase8a程序验证

更新日期:2024年09月11日

编写如下servlet,然后把项目部署到weblogic 上。
package com.gbase.jndi;
import java.io.IOException;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import javax.naming.Context;
import javax.naming.InitialContext;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.sql.DataSource;
public class TestJNDIWithGBase extends HttpServlet {

/**
*
*/
private static final long serialVersionUID = 1L;

/**
* The doGet method of the servlet.

*
* This method is called when a form has its tag value method equals to get.
*

GBase UP 产品手册 6 应用开发指南
文档版本04(2021-04-21) 南大通用数据技术股份有限公司 1058
* @param request the request send by the client to the server
* @param response the response send by the server to the client
* @throws ServletException if an error occurred
* @throws IOException if an error occurred
*/
public void doGet(HttpServletRequest request, HttpServletResponse response)


throws ServletException, IOException {

Connection conn = null;
ResultSet rs = null;
Statement st = null;
try {
Context ctx = new InitialContext();
DataSource ds = (DataSource) ctx.lookup("gbase_jndi");
conn = ds.getConnection();
st = conn.createStatement();
rs = st.executeQuery("select id,name,age,department from emp");
while(rs.next()){
System.out.println("员工id:"+rs.getInt(1)+" 员工姓名:"+rs.getString(2)+"
员工年龄:"+rs.getInt(3)+" 员工部门:"+rs.getString(4));
}
} catch (Exception e) {
e.printStackTrace();
}finally{
if(rs != null){
try {
rs.close();
rs = null;
} catch (SQLException e) {
e.printStackTrace();
}
if(st != null){
try {
st.close();
st = null;
} catch (SQLException e) {
e.printStackTrace();
}
if(conn != null){
try {






conn.close();

GBase UP 产品手册 6 应用开发指南
文档版本04(2021-04-21) 南大通用数据技术股份有限公司 1059






conn = null;
} catch (SQLException e) {
e.printStackTrace();
}
}
}
}
}

/**
* The doPost method of the servlet.

*
* This method is called when a form has its tag value method equals to post.
*
* @param request the request send by the client to the server
* @param response the response send by the server to the client
* @throws ServletException if an error occurred
* @throws IOException if an error occurred
*/
public void doPost(HttpServletRequest request, HttpServletResponse response)


throws ServletException, IOException {

this.doGet(request, response);
}
}
web.xml 配置如下:


xmlns="http://java.sun.com/xml/ns/javaee"

xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

xsi:schemaLocation="http://java.sun.com/xml/ns/javaee

http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">

This is the description of my J2EE component
This is the display name of my J2EE component
TestJNDIWithGBase
com.gbase.jndi.TestJNDIWithGBase



TestJNDIWithGBase
/TestJNDIWithGBase

GBase UP 产品手册 6 应用开发指南
文档版本04(2021-04-21) 南大通用数据技术股份有限公司 1060


index.jsp


当访问如下URL 时:
http://localhost:7001/TestMysqlJNDIWithWeblogic/TestJNDIWithGBase
该测试用例会打印出数据库为test 表为emp 中的内容。

功能描述
删除一个已存在的函数。
注意事项
如果函数中涉及对临时表相关操作,则无法使用DROP FUNCTION 删除函数。
只有函数的所有者或者被授予了函数DROP 权限的用户才能执行DROP FUNCTION 命
令,系统管理员默认拥有该权限。
语法格式
DROP FUNCTION [ IF EXISTS ] function_name
[ ( [ {[ argname ] [ argmode ] argtype} [, ...] ] ) [ CASCADE | RESTRICT ] ];
参数说明

IF EXISTS
IF EXISTS 表示,如果函数存在则执行删除操作,函数不存在也不会报错,只是发出一
个notice。

function_name
要删除的函数名称。
取值范围:已存在的函数名。

argmode
函数参数的模式。

argname
函数参数的名称。

argtype
函数参数的类型。

GBase 8c SQL 参考手册
南大通用数据技术股份有限公司
1114
示例
请参见的示例。
相关命令
ALTER FUNCTION,CREATE FUNCTION


GBase 8s 管理员参考
南大通用数据技术股份有限公司 - 430 -

与一个 GBase 8s 实例相关联的 chunk 不会被其他的 GBase 8s 实例识别。它可能无意中
创建被分配到另一个 GBase 8s 实例文件或设备中的 chunk ,这会导致数据损坏。
如果您尝试初始化一个 ROOTPATH 配置参数指定的文件或设备是别的实例的 root chunk
的实例,那么该命令失败并在 online.log 中显示以下消息:
DISK INITIALIZATION ABORTED: potential instance overwrite detected.
要禁用此次初始化检查,将配置文件中的 FULL_DISK_INIT 配置参数设置为 1 ,并尝试
再次初始化该实例。然而,该初始化检查限制 root chunk。尽管该文件或设备被分配到其
他实例,添加 dbspace 或 chunk 成功。