PreparedStatement pstmt = conn.prepareStatement("CREATE TEMP TABLE inet_tab (ip1 inet, ip2 inet, ip3 inet)");
pstmt.executeUpdate();
pstmt.close();
pstmt = conn.prepareStatement("insert into inet_tab values (?,?,?)");
InetAddr inet1;
InetAddr inet2;
pstmt.setObject(1, inet1 = new InetAddr("2001:4f8:3:ba:2e0:81ff:fe22:d1f1"));
pstmt.setObject(2, inet2 = new InetAddr("192.168.100.128/25"));
pstmt.setObject(3, null, Types.OTHER);
pstmt.executeUpdate();
pstmt.close();
pstmt = conn.prepareStatement("select * from inet_tab");
ResultSet rs = pstmt.executeQuery();
assertTrue(rs.next());
assertTrue(rs.getObject(1).getClass() == InetAddr.class);
assertTrue(inet1.equals(rs.getObject(1)));
assertTrue(rs.getObject(2).getClass() == InetAddr.class);
assertTrue(inet2.equals(rs.getObject(2)));
rs.getObject(3);
assertTrue(rs.wasNull());
rs.close();
pstmt.close();
}