pg-jdbc

pass unknown number of parameters to IN clause using JDBC and Postgres

房东的猫 提交于 2019-12-11 16:46:31
问题 My query looks like this, and performs well: select * from table t where (t.one,t.two,t.three) in ( (11,12,13), (21,22,23) ); Now the number of these triplets within the in statement will vary, so I'm trying to do the following with JDBC: String sql = "select * from table where (one, two, three) in (select * from unnest(?::smallint[], ?::integer[], ?::integer[]))" // conn is the java.sql.Connection PreparedStatement ps = conn.prepareStatement(sql); ps.setArray(1, conn.createArrayOf("smallint"

LISTEN/NOTIFY pgconnection goes down java?

徘徊边缘 提交于 2019-12-04 20:38:09
问题 I am using PostgreSQL DB and applying it's LISTEN/NOTIFY functionality. So my listener is at my AS (Application Server) and I have triggers configured on my DB such that when CRUD operations are performed on a table a NOTIFY request is sent on AS. LISTENER class in java: @Singleton @Startup NotificationListenerInterface.class) public class NotificationListener extends Thread implements NotificationListenerInterface { @Resource(mappedName="java:/RESOURCES") private DataSource ds;

LISTEN/NOTIFY pgconnection goes down java?

夙愿已清 提交于 2019-12-03 13:31:45
I am using PostgreSQL DB and applying it's LISTEN/NOTIFY functionality. So my listener is at my AS (Application Server) and I have triggers configured on my DB such that when CRUD operations are performed on a table a NOTIFY request is sent on AS. LISTENER class in java: @Singleton @Startup NotificationListenerInterface.class) public class NotificationListener extends Thread implements NotificationListenerInterface { @Resource(mappedName="java:/RESOURCES") private DataSource ds; @PersistenceContext(unitName = "one") EntityManager em; Logger logger = Logger.getLogger(NotificationListener.class)

Postgres UUID JDBC not working

流过昼夜 提交于 2019-11-27 23:38:29
The latest Java JDBC drivers for postgres claim to support UUIDs natively; working against Postgres 9.2 (mac). Indeed, when a PreparedStatement is used, I can step through the driver code, and even walk through the specialised 'setUuid' function in AbstractJdbc3gStatement.java. By all indications, it should 'just work'. However, it does not work. The database flings back an error, which I receive thus: Caused by: org.postgresql.util.PSQLException: ERROR: operator does not exist: uuid = bytea Hint: No operator matches the given name and argument type(s). You might need to add explicit type

Postgres UUID JDBC not working

拈花ヽ惹草 提交于 2019-11-27 04:41:15
问题 The latest Java JDBC drivers for postgres claim to support UUIDs natively; working against Postgres 9.2 (mac). Indeed, when a PreparedStatement is used, I can step through the driver code, and even walk through the specialised 'setUuid' function in AbstractJdbc3gStatement.java. By all indications, it should 'just work'. However, it does not work. The database flings back an error, which I receive thus: Caused by: org.postgresql.util.PSQLException: ERROR: operator does not exist: uuid = bytea