返回首页

gbase数据、南大通用产品文档:GBase8aDATE(expr)

更新日期:2024年09月11日

函数说明
从date 或者datetime 表达式expr 中取得日期部分。
如果expr 是一个非法日期字符串,则返回NULL。
示例
示例1:从datetime 表达式中取得日期部分。
gbase> SELECT DATE('2019-09-05 11:22:03') FROM dual;
+-----------------------------+
| DATE('2019-09-05 11:22:03') |
+-----------------------------+
| 2019-09-05
|

GBase 8a MPP Cluster 产品手册
5 数据库管理指南
文档版本953(2022-09-15)
南大通用数据技术股份有限公司
785
+-----------------------------+
1 row in set
示例2:expr 是一个非法日期字符串,则返回NULL。
gbase> SELECT DATE('2019-09-32 11:22:03') FROM dual;
+-----------------------------+
| DATE('2019-09-32 11:22:03') |
+-----------------------------+
| NULL
|
+-----------------------------+
1 row in set, 1 warning
gbase> SHOW WARNINGS;
+-------+------+---------------------------------------------------------------------+
| Level | Code | Message
|
+-------+------+---------------------------------------------------------------------+
| Note
| 1292 |172.168.83.11:5050 - Incorrect datetime value: '2019-09-32
11:22:03' |
+-------+------+---------------------------------------------------------------------+
1 row in set (Elapsed: 00:00:00.00)

krb5kdc 为GBase 8c 认证服务Kerberos 提供列认证和秘钥管理服务。

程序验证
编写如下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.
*
* @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

GBase 8a 程序员手册JDBC 篇


- 90 -

南大通用数据技术股份有限公司
*/
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();
}

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

- 91 -
if(conn != null){
try {






conn.close();






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"

GBase 8a 程序员手册JDBC 篇


- 92 -

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

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.TestJNDIWithGBaseass>



TestJNDIWithGBase
/TestJNDIWithGBase


index.jsp


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