notifytest.java
来自「PostgreSQL7.4.6 for Linux」· Java 代码 · 共 44 行
JAVA
44 行
package org.postgresql.test.jdbc2;import org.postgresql.test.TestUtil;import junit.framework.TestCase;import java.sql.*;import org.postgresql.PGConnection;import org.postgresql.PGNotification;public class NotifyTest extends TestCase{ private Connection conn; public NotifyTest(String name) { super(name); } protected void setUp() throws SQLException { conn = TestUtil.openDB(); } protected void tearDown() throws SQLException { TestUtil.closeDB(conn); } public void testNotify() throws SQLException { Statement stmt = conn.createStatement(); stmt.executeUpdate("LISTEN mynotification"); stmt.executeUpdate("NOTIFY mynotification"); PGNotification notifications[] = ((org.postgresql.PGConnection)conn).getNotifications(); assertNotNull(notifications); assertEquals(notifications.length, 1); assertEquals(notifications[0].getName(), "mynotification"); stmt.close(); }}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?