1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54
|
/*-------------------------------------------------------------------------
*
* Copyright (c) 2007-2008, PostgreSQL Global Development Group
*
* IDENTIFICATION
* $PostgreSQL: pgjdbc/org/postgresql/test/jdbc4/LOBTest.java,v 1.2 2008/01/08 06:56:31 jurka Exp $
*
*-------------------------------------------------------------------------
*/
package org.postgresql.test.jdbc4;
import java.sql.*;
import junit.framework.TestCase;
import org.postgresql.test.TestUtil;
public class LOBTest extends TestCase {
private Connection _conn;
public LOBTest(String name) {
super(name);
}
protected void setUp() throws Exception {
_conn = TestUtil.openDB();
Statement stmt = _conn.createStatement();
stmt.execute("CREATE TEMP TABLE lotest(lo oid)");
stmt.execute("INSERT INTO lotest VALUES(lo_creat(-1))");
stmt.close();
}
protected void tearDown() throws SQLException {
Statement stmt = _conn.createStatement();
stmt.execute("DROP TABLE lotest");
stmt.close();
TestUtil.closeDB(_conn);
}
public void testFree() throws SQLException {
_conn.setAutoCommit(false);
Statement stmt = _conn.createStatement();
ResultSet rs = stmt.executeQuery("SELECT lo FROM lotest");
assertTrue(rs.next());
Blob blob = rs.getBlob(1);
blob.free();
try {
blob.length();
fail("Should have thrown an Exception because it was freed.");
} catch (SQLException sqle) {
}
}
}
|