AS AgentScopeAPI 手册 / API Reference

AbstractJdbcDialect

public abstract class AbstractJdbcDialect implements StoreDialect, SessionStateDialect, SnapshotDialect, SandboxLockStrategy
源码Source io/agentscope/extensions/jdbc/dialect/AbstractJdbcDialect.java:64–368

抽象 JDBC Dialect,在多次调用之间保存和恢复会话与记忆数据。位于 io.agentscope.extensions.jdbc.dialect 包,实现 StoreDialect、SessionStateDialect、SnapshotDialect、SandboxLockStrategy。核心成员包括 storeTableName、sessionStateTableName、snapshotTableName、createTableDdls、bindDataSource、getDataSource。

Aggregate dialect abstract class — implements all table-domain interfaces and the SandboxLockStrategy contract.

Holds a unified table prefix and per-table name overrides. Vendor classes extend this class and override only the methods where their SQL diverges from ANSI defaults. Lock behavior is also overridable: the default #tryEnter uses a portable table-based lock; vendor dialects with native advisory locks (e.g. MySQL GET_LOCK, PostgreSQL pg_try_advisory_lock) override tryEnter.

Table-name resolution priority: per-table override > prefix + base. The final resolution methods lock the logic in the base class; vendor dialects inherit them and read the assembled names.

Fields are mutable at assembly time (set by AbstractJdbcDialectBuilder) and effectively read-only after build() returns.

Auto-detection

#from(DataSource) returns a AbstractJdbcDialectBuilder that uses JDK SPI (java.util.ServiceLoader) to discover all dialect implementations on the classpath. Dialects are sorted by #getOrder() (ascending) then by inheritance depth (child before parent). The first dialect whose #supports(DatabaseMetaData) returns true wins.

方法摘要Method Summary

方法Method说明Description
public final String storeTableName()
final
返回 `storeTableName` 结果。
Returns the store table name.
public final String sessionStateTableName()
final
返回 `sessionStateTableName` 结果。
Returns the session state table name.
public final String snapshotTableName()
final
返回 `snapshotTableName` 结果。
Returns the snapshot table name.
protected List<String> createTableDdls()
创建 `createTableDdls`。
Collects create-schema DDL for all table-domain interfaces, executed by the builder in a single connection during `build()`.
public void bindDataSource(DataSource dataSource)
设置该参数。
Binds the DataSource used for lock acquisition.
protected DataSource getDataSource()
获取数据来源。
Returns the bound DataSource (for vendor lock implementations).
public static void closeConnection(Connection con)
static
关闭连接。
Closes a JDBC connection quietly, returning it to the pool when pooled.
public static void closeStatement(Statement stmt)
static
关闭 `closeStatement`。
Closes a JDBC statement quietly.
public static void closeResultSet(ResultSet rs)
static
关闭结果设置。
Closes a JDBC result set quietly.
public abstract boolean supports(DatabaseMetaData metaData) throws SQLException
abstract
设置支持。
Whether this dialect supports the target database.
public int getOrder()
获取顺序。
Detection priority (lower wins).
protected String lockTableName()
返回 `lockTableName` 结果。
Lock table name, derived from the table prefix.
public SandboxLease tryEnter(String lockName, int timeoutSeconds) throws InterruptedException
执行 `tryEnter` 方法。
Performs the try enter operation.
public static AbstractJdbcDialectBuilder from(DataSource dataSource)
static
创建并返回实例。
Entry point for auto-detection.

方法详情Method Detail

storeTableName

public final String storeTableName()
final

返回 storeTableName 结果。

Returns the store table name.

返回Returns String
返回字符串结果。Returns a string.
源码Source io/agentscope/extensions/jdbc/dialect/AbstractJdbcDialect.java:92–96

sessionStateTableName

public final String sessionStateTableName()
final

返回 sessionStateTableName 结果。

Returns the session state table name.

返回Returns String
返回字符串结果。Returns a string.
源码Source io/agentscope/extensions/jdbc/dialect/AbstractJdbcDialect.java:98–103

snapshotTableName

public final String snapshotTableName()
final

返回 snapshotTableName 结果。

Returns the snapshot table name.

返回Returns String
返回字符串结果。Returns a string.
源码Source io/agentscope/extensions/jdbc/dialect/AbstractJdbcDialect.java:105–110

createTableDdls

protected List<String> createTableDdls()

创建 createTableDdls。

Collects create-schema DDL for all table-domain interfaces, executed by the builder in a single connection during build().

返回Returns List<String>
返回列出。all DDL statements, in store → sessions → snapshots order
源码Source io/agentscope/extensions/jdbc/dialect/AbstractJdbcDialect.java:124–130

bindDataSource

public void bindDataSource(DataSource dataSource)

设置该参数。

Binds the DataSource used for lock acquisition.

参数Parameters
名称Name类型Type说明Description
dataSourceDataSource数据来源(类型 `DataSource`)。The data source.
源码Source io/agentscope/extensions/jdbc/dialect/AbstractJdbcDialect.java:160–170

getDataSource

protected DataSource getDataSource()

获取数据来源。

Returns the bound DataSource (for vendor lock implementations).

返回Returns DataSource
返回DataSource。Returns data source.
源码Source io/agentscope/extensions/jdbc/dialect/AbstractJdbcDialect.java:173–180

closeConnection

public static void closeConnection(Connection con)
static

关闭连接。

Closes a JDBC connection quietly, returning it to the pool when pooled.

参数Parameters
名称Name类型Type说明Description
conConnectioncon(类型 `Connection`)。The con.
源码Source io/agentscope/extensions/jdbc/dialect/AbstractJdbcDialect.java:187–197

closeStatement

public static void closeStatement(Statement stmt)
static

关闭 closeStatement。

Closes a JDBC statement quietly.

参数Parameters
名称Name类型Type说明Description
stmtStatementstmt(类型 `Statement`)。The stmt.
源码Source io/agentscope/extensions/jdbc/dialect/AbstractJdbcDialect.java:200–210

closeResultSet

public static void closeResultSet(ResultSet rs)
static

关闭结果设置。

Closes a JDBC result set quietly.

参数Parameters
名称Name类型Type说明Description
rsResultSetrs(类型 `ResultSet`)。The rs.
源码Source io/agentscope/extensions/jdbc/dialect/AbstractJdbcDialect.java:213–223

supports

public abstract boolean supports(DatabaseMetaData metaData) throws SQLException
abstract

设置支持。

Whether this dialect supports the target database.

参数Parameters
名称Name类型Type说明Description
metaDataDatabaseMetaData元数据(类型 `DatabaseMetaData`)。JDBC metadata (connection stays open)
返回Returns boolean
返回布尔值,表示判断结果。true if this dialect handles the database
抛出Throws
  • SQLException 可能抛出 `SQLException`。Thrown when the operation cannot be completed.
源码Source io/agentscope/extensions/jdbc/dialect/AbstractJdbcDialect.java:236

getOrder

public int getOrder()

获取顺序。

Detection priority (lower wins).

返回Returns int
返回数值结果。Returns a numeric result.
源码Source io/agentscope/extensions/jdbc/dialect/AbstractJdbcDialect.java:241–243

lockTableName

protected String lockTableName()

返回 lockTableName 结果。

Lock table name, derived from the table prefix.

返回Returns String
返回字符串结果。Returns a string.
源码Source io/agentscope/extensions/jdbc/dialect/AbstractJdbcDialect.java:253–255

tryEnter

public SandboxLease tryEnter(String lockName, int timeoutSeconds) throws InterruptedException

执行 tryEnter 方法。

Performs the try enter operation.

参数Parameters
名称Name类型Type说明Description
lockNameString锁名称(类型 `String`)。The lock name.
timeoutSecondsint超时秒(类型 `int`)。The timeout seconds.
返回Returns SandboxLease
返回SandboxLease。Returns sandbox lease.
抛出Throws
  • InterruptedException 可能抛出 `InterruptedException`。Thrown when the operation cannot be completed.
源码Source io/agentscope/extensions/jdbc/dialect/AbstractJdbcDialect.java:257–294

from

public static AbstractJdbcDialectBuilder from(DataSource dataSource)
static

创建并返回实例。

Entry point for auto-detection.

参数Parameters
名称Name类型Type说明Description
dataSourceDataSource数据来源(类型 `DataSource`)。The data source.
返回Returns AbstractJdbcDialectBuilder
返回AbstractJdbcDialectBuilder。Returns abstract jdbc dialect builder.
源码Source io/agentscope/extensions/jdbc/dialect/AbstractJdbcDialect.java:362–367

继承成员Inherited Members

基于官方固定版本源码静态生成Generated from pinned official sources · Python 2.0.11 · Java 2.0.4
签名与文档为静态抽取;如有疑问请以源码为准。Signatures and docs are extracted statically; verify against the source when in doubt.