鸿蒙OS开发文档

鸿蒙OS Ability-国外主机测评 - 国外VPS,国外服务器,国外云服务器,测评及优惠码

鸿蒙OS Ability

Ability是 HarmonyOS 应用程序可以提供的功能的抽象。HarmonyOS 应用程序的Ability分为两种类型:特征Ability和粒子Ability。特征Ability代表具有 UI 的功能,并旨在与用户进行交互。粒子Ability表示没有 UI 的Ability,并且主要用于提供对 FA 的支持,例如,提供计算功能作为后台服务或提供数据访问功能作为数据存储库。两种功能为您提供了不同的模板,以供您实现不同的功能。当前,HarmonyOS 提供以下类型的Ability模板: 注意:在下面的描述中,页面,服务或数据功能表示使用相应模板的功能,而单独的功能表示使用任何类型的模板的功能。 页面:显示 UI 的功能。UI 通过 AbilitySlice 呈现。您必须重写 onStart(ohos.aafwk.content.Intent)方法,并使用 setMainRoute(java.lang.String) 和addActionRoute(java.lang.String,java.lang.String)方法来配置 Page 功能的条目。 服务:一种在后台运行且没有 UI 的功能。它用于开发始终在后台运行或与其他功能连接的服务。当服务Ability与其他Ability连接时,将返回一个远程对象,您可以使用该远程对象来调用该服务Ability提供的功能。 数据:一种用于操作数据且没有 UI 的功能。它提供了用于插入,删除,更新和查询数据以及打开文件的方法。您必须实现这些方法。 Ability简介 每个应用程序都有一个配置文件:config.json。该文件存储在Java代码的根目录中。 ├── entry │ ├── libs │ ├── src │ │ ├── main │ │ │ ├── java │ │ │ │ └── com │ │ │ │ └── example │ │ │ │ └── myapplication │ │ │ │ ├── slice │ │ │ │ │ └── PageAbilitySlice.java │ │ │ │ └── PageAbility.java │ │ │ ├── resources │ │ │ │ ├── base │ │ │ │ │ ├── element │ │ │ │ │ │ └── string.json │ │ │ │ │ └── media │ │...

鸿蒙OS StatementEvent

StatementEvent java.lang.Object |—java.util.EventObject |—|—javax.sql.StatementEvent public class StatementEvent extends EventObject StatementEvent 被发送到所有向 PooledConnection 注册的 StatementEventListener。 当驱动程序确定与 PooledConnection 关联的 PreparedStatement 已关闭或驱动程序确定无效时,会发生这种情况。 Since: 1.6 字段摘要 从类 java.util.EventObject 继承的字段 source 构造函数摘要 构造函数 描述 StatementEvent(PooledConnection con, PreparedStatement statement) 使用指定的 PooledConnection 和 PreparedStatement 构造一个 StatementEvent。 StatementEvent(PooledConnection con, PreparedStatement statement, SQLException exception) 使用指定的 PooledConnection、PreparedStatement 和 SQLException 构造一个 StatementEvent 方法总结 修饰符和类型 方法 描述 SQLException getSQLException() 返回驱动程序即将抛出的 SQLException PreparedStatement getStatement() 返回正在关闭或无效的 PreparedStatement 从类 java.util.EventObject 继承的方法 getSource, toString 从类 java.lang.Object 继承的方法 clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait 构造函数详细信息 StatementEvent public StatementEvent(PooledConnection con, PreparedStatement statement) 使用指定的 PooledConnection 和 PreparedStatement 构造一个 StatementEvent。 事件中包含的 SQLException 默认为 null。 参数: 参数名称 参数描述 con 与关闭或无效 PreparedStatement 关联的 PooledConnection。 statement 正在关闭或无效的 PreparedStatement Throws: Throw名称 Throw描述 IllegalArgumentException 如果 con 为空。 Since: 1.6 StatementEvent public StatementEvent(PooledConnection con, PreparedStatement statement, SQLException exception) 使用指定的 PooledConnection、PreparedStatement 和 SQLException 构造一个 StatementEvent 参数: 参数名称 参数描述 con 与关闭或无效 PreparedStatement 关联的 PooledConnection。 statement 正在关闭或无效的 PreparedStatement exception 驱动程序即将向应用程序抛出的 SQLException Throws: Throw名称 Throw描述 IllegalArgumentException 如果 con 为空。 Since: 1.6 方法详情 getStatement public PreparedStatement getStatement() 返回正在关闭或无效的 PreparedStatement 返回:...

鸿蒙OS RowSetEvent

RowSetEvent java.lang.Object |—java.util.EventObject |—|—javax.sql.RowSetEvent public class RowSetEvent extends EventObject 当 RowSet 对象发生事件时生成的 Event 对象。 当更改行集中的单个行、更改整个行集或行集游标移动时,将生成 RowSetEvent 对象。 当 RowSet 对象上发生事件时,RowSetListener 方法之一将被发送到所有已注册的侦听器以通知它们该事件。 向 RowSetListener 方法提供一个 Event 对象,以便侦听器可以使用它来找出哪个 RowSet 对象是事件源。 Since: 1.4 字段摘要 从类 java.util.EventObject 继承的字段 source 构造函数摘要 构造函数 描述 RowSetEvent(RowSet source) 构造使用给定 RowSet 对象初始化的 RowSetEvent 对象。 方法总结 从类 java.util.EventObject 继承的方法 getSource, toString 从类 java.lang.Object 继承的方法 clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait 构造函数详细信息 RowSetEvent public RowSetEvent(RowSet source) 构造使用给定 RowSet 对象初始化的 RowSetEvent 对象。 参数: 参数名称 参数描述 source 数据已更改或光标已移动的 RowSet 对象 Throws: Throw名称 Throw描述 IllegalArgumentException 如果 source 为空。

鸿蒙OS ConnectionEvent

ConnectionEvent java.lang.Object |—java.util.EventObject |—|—javax.sql.ConnectionEvent public class ConnectionEvent extends EventObject 一个 Event 对象,提供有关连接相关事件的来源的信息。 ConnectionEvent 对象在应用程序关闭池连接和发生错误时生成。 ConnectionEvent 对象包含两种信息: 应用程序关闭的池连接 在发生错误事件的情况下,将向应用程序抛出 SQLException Since: 1.4 字段摘要 从类 java.util.EventObject 继承的字段 source 构造函数摘要 构造函数 描述 ConnectionEvent(PooledConnection con) 构造一个使用给定的 PooledConnection 对象初始化的 ConnectionEvent 对象。 ConnectionEvent(PooledConnection con, SQLException ex) 构造一个使用给定的 PooledConnection 对象和 SQLException 对象初始化的 ConnectionEvent 对象。 方法总结 修饰符和类型 方法 描述 SQLException getSQLException() 检索此 ConnectionEvent 对象的 SQLException。 从类 java.util.EventObject 继承的方法 getSource, toString 从类 java.lang.Object 继承的方法 clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait 构造函数详细信息 ConnectionEvent public ConnectionEvent(PooledConnection con) 构造一个使用给定的 PooledConnection 对象初始化的 ConnectionEvent 对象。 SQLException 默认为空。 参数: 参数名称 参数描述 con 作为事件源的池连接 Throws: Throw名称 Throw描述 IllegalArgumentException 如果 con 为空。 ConnectionEvent public ConnectionEvent(PooledConnection con, SQLException ex) 构造一个使用给定的 PooledConnection 对象和 SQLException 对象初始化的 ConnectionEvent 对象。 参数: 参数名称 参数描述 con 作为事件源的池连接 ex 即将向应用程序抛出的 SQLException Throws: Throw名称 Throw描述 IllegalArgumentException 如果 con 为空。 方法详情 getSQLException public SQLException getSQLException() 检索此 ConnectionEvent 对象的 SQLException。 可能为空。 返回: 即将抛出的 SQLException 或 null

鸿蒙OS StatementEventListener

StatementEventListener public interface StatementEventListener extends EventListener 一个对象,它注册以通知在语句池中的 PreparedStatements 上发生的事件。 JDBC 3.0 规范添加了 maxStatements ConnectionPooledDataSource 属性,以提供启用 PreparedStatements 池的标准机制并指定语句池的大小。但是,当 PreparedStatement 无效时,驱动程序无法通知外部语句池。对于某些数据库,如果执行了影响表的 DDL 操作,则语句将变为无效。例如,应用程序可能会创建一个临时表来对该表执行一些工作,然后将其销毁。它可能会在以后再次需要时重新创建同一个表。某些数据库会在删除表时使引用临时表的任何准备好的语句无效。 与 ConnectionEventListener 接口中定义的方法类似,驱动程序在检测到语句无效时会在抛出任何异常之前调用 StatementEventListener.statementErrorOccurred 方法。当 PreparedStatement 关闭时,驱动程序还将调用 StatementEventListener.statementClosed 方法。 允许组件向 PooledConnection 注册 StatementEventListener 的方法已添加到 PooledConnection 接口中。 Since: 1.6 方法总结 修饰符和类型 方法 描述 void statementClosed(StatementEvent event) 驱动程序在检测到 PreparedStatement 已关闭时,对连接上注册的所有 StatementEventListener 调用此方法。 void statementErrorOccurred(StatementEvent event) 驱动程序在检测到 PreparedStatement 无效时,对连接上注册的所有 StatementEventListener 调用此方法。 方法详情 statementClosed void statementClosed(StatementEvent event) 驱动程序在检测到 PreparedStatement 已关闭时,对连接上注册的所有 StatementEventListener 调用此方法。 参数: 参数名称 参数描述 event 描述事件源和 PreparedStatement 已关闭的事件对象。 Since: 1.6 statementErrorOccurred void statementErrorOccurred(StatementEvent event) 驱动程序在检测到 PreparedStatement 无效时,对连接上注册的所有 StatementEventListener 调用此方法。 驱动程序在将给定事件中包含的 SQLException 抛出给应用程序之前调用此方法。 参数: 参数名称 参数描述 event 一个事件对象,描述事件的来源、无效的语句以及驱动程序即将抛出的异常。 事件的来源是与无效 PreparedStatement 关联的 PooledConnection。 Since: 1.6

鸿蒙OS RowSetWriter

RowSetWriter public interface RowSetWriter 实现 RowSetWriter 接口的对象,称为编写器。 可以使用支持读取器/写入器范例的 RowSet 对象注册写入器。 如果一个断开连接的 RowSet 对象修改了它的一些数据,并且它有一个与之关联的写入器,则可以实现它以便它在内部调用写入器的 writeData 方法以将更新写回数据源。 为此,编写器必须首先与行集的数据源建立连接。 如果要更新的数据已经在数据源中发生了变化,则存在冲突,这种情况下写入者不会将这些变化写入数据源。 作者用于防止或限制冲突的算法完全取决于其实现。 Since: 1.4 方法总结 修饰符和类型 方法 描述 boolean writeData(RowSetInternal caller) 将此 RowSetWriter 对象的行集中的更改写回它从中获取数据的数据源。 方法详情 writeData boolean writeData(RowSetInternal caller) throws SQLException 将此 RowSetWriter 对象的行集中的更改写回它从中获取数据的数据源。 参数: 参数名称 参数描述 caller RowSet 对象 (1) 已实现 RowSetInternal 接口,(2) 此 writer 注册的对象,以及 (3) 在内部调用此方法 返回: 如果已写入修改的数据,则为 true; 如果没有,则为 false,如果存在冲突,则为这种情况 Throws: Throw名称 Throw描述 SQLException 如果发生数据库访问错误

鸿蒙OS RowSetReader

RowSetReader public interface RowSetReader 断开连接的 RowSet 对象调用以使用数据行填充自身的工具。 读取器(实现 RowSetReader 接口的对象)可以注册到支持读取器/写入器范例的 RowSet 对象。 当调用 RowSet 对象的 execute 方法时,它会依次调用 reader 的 readData 方法。 Since: 1.4 方法总结 修饰符和类型 方法 描述 void readData(RowSetInternal caller) 读取调用 RowSet 对象的新内容。 方法详情 readData void readData(RowSetInternal caller) throws SQLException 读取调用 RowSet 对象的新内容。 为了调用此方法,RowSet 对象必须已实现 RowSetInternal 接口并将此 RowSetReader 对象注册为其读取器。 readData 方法由支持读取器/写入器范例的行集的 RowSet.execute 方法在内部调用。 readData 方法向调用者添加行。 它可以以多种方式实现,甚至可以使用来自非关系数据源的行来填充调用者。 通常,读取器可以调用任何行集的方法,但有一个例外。 调用方法execute 将导致抛出SQLException,因为可能不会递归调用execute。 此外,当阅读器调用 RowSet 方法时,不会通知任何侦听器; 也就是说,不会生成任何 RowSetEvent 对象,也不会调用任何 RowSetListener 方法。 这是真的,因为方法 execute 已经通知了侦听器。 参数: 参数名称 参数描述 caller RowSet 对象 (1) 实现了 RowSetInternal 接口,(2) 注册了此阅读器,以及 (3) 其执行方法调用了此阅读器 Throws: Throw名称 Throw描述 SQLException 如果发生数据库访问错误或此方法调用 RowSet.execute 方法

鸿蒙OS RowSetMetaData

RowSetMetaData public interface RowSetMetaData extends ResultSetMetaData 包含有关 RowSet 对象中的列的信息的对象。 此接口是 ResultSetMetaData 接口的扩展,其中包含用于设置 RowSetMetaData 对象中的值的方法。 当 RowSetReader 对象将数据读入 RowSet 对象时,它会创建一个 RowSetMetaData 对象并使用 RowSetMetaData 接口中的方法对其进行初始化。 然后读取器将 RowSetMetaData 对象传递给行集。 此接口中的方法在应用程序调用方法 RowSet.execute 时在内部调用; 应用程序程序员不会直接使用它们。 Since: 1.4 字段摘要 从接口 java.sql.ResultSetMetaData 继承的字段 columnNoNulls, columnNullable, columnNullableUnknown 方法总结 修饰符和类型 方法 描述 void setAutoIncrement(int columnIndex, boolean property) 设置指定列是否自动编号,默认为 RowSet 对象的列不自动编号。 void setCaseSensitive(int columnIndex, boolean property) 设置指定列是否区分大小写。 void setCatalogName(int columnIndex, String catalogName) 将指定列的表的目录名称(如果有)设置为给定的字符串。 void setColumnCount(int columnCount) 将 RowSet 对象中的列数设置为给定数。 void setColumnDisplaySize(int columnIndex, int size) 将指定列的正常最大宽度(以字符为单位)设置为给定的 int。 void setColumnLabel(int columnIndex, String label) 将建议的列标题设置为用于打印输出和显示(如果有)给给定的字符串。 void setColumnName(int columnIndex, String columnName) 将指定列的名称设置为给定的字符串。 void setColumnType(int columnIndex, int SQLType) 将指定列的 SQL 类型设置为给定的类型。 void setColumnTypeName(int columnIndex, String typeName) 将特定于数据源的指定列的类型名称(如果有)设置为给定的字符串。 void setCurrency(int columnIndex, boolean property) 设置指定列是否为现金值。 void setNullable(int columnIndex, int property) 设置指定列的值是否可以设置为 NULL。 void setPrecision(int columnIndex, int precision) 将指定列的小数位数设置为给定的 int。 void setScale(int columnIndex, int scale) 将指定列的小数点右侧的位数设置为给定的 int。 void setSchemaName(int columnIndex, String schemaName) 将指定列的表模式的名称(如果有)设置为给定的字符串。 void setSearchable(int columnIndex, boolean property) 设置指定列是否可以在 where 子句中使用。 void setSigned(int columnIndex, boolean property) 设置指定列是否为有符号数。 void setTableName(int columnIndex, String tableName) 将指定列的表名(如果有)设置为给定的字符串。 从接口 java.sql.ResultSetMetaData 继承的方法 getCatalogName, getColumnClassName, getColumnCount, getColumnDisplaySize, getColumnLabel, getColumnName, getColumnType, getColumnTypeName, getPrecision, getScale, getSchemaName, getTableName, isAutoIncrement, isCaseSensitive, isCurrency, isDefinitelyWritable, isNullable, isReadOnly, isSearchable, isSigned, isWritable 从接口 java.sql.Wrapper 继承的方法 isWrapperFor, unwrap 方法详情 setColumnCount void setColumnCount(int columnCount) throws SQLException 将 RowSet 对象中的列数设置为给定数。 参数: 参数名称 参数描述 columnCount RowSet 对象中的列数 Throws: Throw名称 Throw描述 SQLException 如果发生数据库访问错误...

鸿蒙OS RowSetListener

RowSetListener public interface RowSetListener extends EventListener 一个必须由组件实现的接口,该组件希望在 RowSet 对象的生命周期中发生重大事件时得到通知。 组件通过通过方法 RowSet.addRowSetListener 注册到 RowSet 对象而成为侦听器。 注册组件如何实现此接口决定了它在收到事件通知时会做什么。 Since: 1.4 方法总结 修饰符和类型 方法 描述 void cursorMoved(RowSetEvent event) 通知已注册的侦听器 RowSet 对象的光标已移动。 void rowChanged(RowSetEvent event) 通知已注册的侦听器 RowSet 对象的其中一行发生了更改。 void rowSetChanged(RowSetEvent event) 通知已注册的侦听器给定 RowSetEvent 对象中的 RowSet 对象已更改其全部内容。 方法详情 rowSetChanged void rowSetChanged(RowSetEvent event) 通知已注册的侦听器给定 RowSetEvent 对象中的 RowSet 对象已更改其全部内容。 可以使用 event.getSource 方法检索事件的来源。 参数: 参数名称 参数描述 event 包含作为事件源的 RowSet 对象的 RowSetEvent 对象 rowChanged void rowChanged(RowSetEvent event) 通知已注册的侦听器 RowSet 对象的其中一行发生了更改。 可以使用 event.getSource 方法检索事件的来源。 参数: 参数名称 参数描述 event 包含作为事件源的 RowSet 对象的 RowSetEvent 对象 cursorMoved void cursorMoved(RowSetEvent event) 通知已注册的侦听器 RowSet 对象的光标已移动。 可以使用 event.getSource 方法检索事件的来源。 参数: 参数名称 参数描述 event 包含作为事件源的 RowSet 对象的 RowSetEvent 对象

鸿蒙OS RowSetInternal

RowSetInternal public interface RowSetInternal RowSet 对象为了将自身呈现给 RowSetReader 或 RowSetWriter 对象而实现的接口。 RowSetInternal 接口包含允许读取器或写入器访问和修改行集的内部状态的方法。 Since: 1.4 方法总结 修饰符和类型 方法 描述 Connection getConnection() 检索传递给此 RowSet 对象的 Connection 对象。 ResultSet getOriginal() 检索包含此 RowSet 对象的原始值的 ResultSet 对象。 ResultSet getOriginalRow() 检索仅包含当前行的原始值的 ResultSet 对象。 Object[] getParams() 检索已为此 RowSet 对象的命令设置的参数。 void setMetaData(RowSetMetaData md) 将给定的 RowSetMetaData 对象设置为此 RowSet 对象的 RowSetMetaData 对象。 方法详情 getParams Object[] getParams() throws SQLException 检索已为此 RowSet 对象的命令设置的参数。 返回: 此 RowSet 对象的命令的当前参数值数组 Throws: Throw名称 Throw描述 SQLException 如果发生数据库访问错误 getConnection Connection getConnection() throws SQLException 检索传递给此 RowSet 对象的 Connection 对象。 返回: 传递给行集的 Connection 对象,如果没有传递,则为 null Throws: Throw名称 Throw描述 SQLException 如果发生数据库访问错误 setMetaData void setMetaData(RowSetMetaData md) throws SQLException 将给定的 RowSetMetaData 对象设置为此 RowSet 对象的 RowSetMetaData 对象。 与行集关联的 RowSetReader 对象将使用 RowSetMetaData 方法来设置提供有关行集列的信息的值。 参数: 参数名称 参数描述 md 将使用有关行集列的信息设置的 RowSetMetaData 对象 Throws: Throw名称 Throw描述 SQLException 如果发生数据库访问错误 getOriginal ResultSet getOriginal() throws SQLException 检索包含此 RowSet 对象的原始值的 ResultSet 对象。 游标位于结果集中的第一行之前。 只有包含在由方法 getOriginal 返回的结果集中的行才被称为具有原始值。 返回: 行集的原始值 Throws: Throw名称 Throw描述 SQLException 如果发生数据库访问错误...