返回首页

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

更新日期:2024年09月11日

功能说明
记录用户安全信息。
表结构说明
表5- 307 表结构信息说明:




Host
主机IP
User
用户名
attempt
密码重试次数
last_attempt
最近成功登录的的重试次数
locked
用户是否锁定
password_expired
密码是否过期
password_last_changed
最近修改密码时间
password_life_time
密码有效期,单位:天
password_history
密码历史列表,密文
host_list
允许登录的host 列表
login_time
本次登录时间
login_host
本次登录主机
last_login_time
最近登录时间
last_login_host
最近登录主机
login_count
用户登录次数

GBase 自动关闭连接问题
我有一个小服务程序/应用程序正常地工作了一白天,
然后晚上就停止工作
了:
回答:
GBase 在无活动8 小时后就自动关闭连接。你或许需要使用能处理失效连
接的连接池。
此外,用户应该在应用程序中捕获SQL 异常并处理它们,而不是一直传播
它们直到用户的程序退出,这只是一个好的编程习惯。当在处理查询过程中遇
到网络连通性问题时,GBase JDBC 会把SQLState (参见用户的APIDOCS 中的

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

- 183 -
java.sql.SQLException.getSQLState()) 置为 “08S01” 。这时用户的程序
应该重新连接GBase 。
下面(简单的)例子说明了什么样的代码可以处理这理这些异常: 使用重
试逻辑的事务例子
public void doBusinessOp() throws SQLException
{
Connection conn = null;
Statement stmt = null;
ResultSet rs = null;
//
// How many times do you want to retry the transaction
// (or at least _getting_ a connection)?
//
int retryCount = 5;
boolean transactionCompleted = false;
do {
try {
conn = getConnection(); // assume getting this from a
// javax.sql.DataSource, or the
// java.sql.DriverManager
conn.setAutoCommit(false);
//
// Okay, at this point, the 'retry-ability' of the
//
transaction
really
depends
on
your
application
logic,
// whether or not you're using autocommit (in this case
//
not),
and
whether
you're
using
transacational
storage
// engines
//
// For this example, we'll assume that it's _not_ safe
//
to
retry
the
entire
transaction,
so
we
set
retry
count
// to 0 at this point
//
// If you were using exclusively transaction-safe
tables,
// or your application could recover from a connection

GBase 8a 程序员手册JDBC 篇


- 184 -

南大通用数据技术股份有限公司
going
//
bad
in
the
middle
of
an
operation,
then
you
would
not
//
touch
'retryCount'
here,
and
just
let
the
loop
repeat
// until retryCount == 0.
//
retryCount = 0;
stmt = conn.createStatement();
String query = "SELECT foo FROM bar ORDER BY baz";
rs = stmt.executeQuery(query);
while (rs.next()) {}
rs.close();
rs = null;
stmt.close();
stmt = null;
conn.commit();
conn.close();
conn = null;
transactionCompleted = true;
} catch (SQLException sqlEx) {
//
// The two SQL states that are 'retry-able' are 08S01
// for a communications error, and 41000 for deadlock.
//
//
Only
retry
if
the
error
was
due
to
a
stale
connection,
// communications problem or deadlock
//
String sqlState = sqlEx.getSQLState();
if ("08S01".equals(sqlState) ||
"41000".equals(sqlState)) {
retryCount--;
}else {
retryCount = 0;
}
} finally {
if (rs != null) {
try {
rs.close();

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

- 185 -
} catch (SQLException sqlEx) {
// You'd probably want to log this . . .
}
}
if (stmt != null) {
try {
stmt.close();
} catch (SQLException sqlEx) {
//
You'd
probably
want
to
log
this
as
well
.
.
.
}
}
if (conn != null) {
try {
//
// If we got here, and conn is not null, the
// transaction should be rolled back, as not
// all work has been done
try {
conn.rollback();
} finally {
conn.close();
}
} catch (SQLException sqlEx) {
//
// If we got an exception here, something
// pretty serious is going on, so we better
// pass it up the stack, rather than just
// logging it. . .
throw sqlEx;
}
}
}
} while (!transactionCompleted && (retryCount > 0));
}

GBase 8a 程序员手册JDBC 篇


- 186 -

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

使用gsodbc-installer 创建数据源时要用到GBase 8a ODBC 连接字符串。
有关GBase 8a ODBC 连接字符串的相关内容请参考3.4 小节。使用
gsodbc-installer 创建数据源的命令如下:
#gsodbc-installer -s -a -c2 -n "test" -t "DRIVER=GBase 8a ODBC 8.3
Driver;UID=gbase;PWD=
gbase20110531; SERVER={192.168.111.96};"