Thread: Eager fetch of Array in one tcp connection
Good day, I'm trying to fetch Array in one row. SQL works well, but when I tried to convert org.postgresql.jdbc4.Jdbc4Array to java Array : allowedMAC = (List<byte[]>) mac.getArray(); I'm getting exception below. This exception is maybe caused by closed connection by org.springframework.jdbc.core.JdbcTemplate . I tried to find out, how to fetch this org.postgresql.jdbc4.Jdbc4Array directly (I have much rows in result and a need to retrieve everything in one question), but function is trying to connect do DB. How should I fetch everything in one select, am I able to disable those "re-question"? Thanks a lot PP Sep 11, 2010 1:00:07 AM cz.admin24.shdb.db.DAO.SwitchportConfig <init> SEVERE: null org.postgresql.util.PSQLException: An I/O error occured while sending to the backend. at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:283) at org.postgresql.jdbc2.AbstractJdbc2Statement.execute(AbstractJdbc2Statement.java:479) at org.postgresql.jdbc2.AbstractJdbc2Statement.executeWithFlags(AbstractJdbc2Statement.java:367) at org.postgresql.jdbc2.TypeInfoCache.getArrayDelimiter(TypeInfoCache.java:335) at org.postgresql.jdbc2.AbstractJdbc2Array.buildArrayList(AbstractJdbc2Array.java:165) at org.postgresql.jdbc2.AbstractJdbc2Array.getArrayImpl(AbstractJdbc2Array.java:138) at org.postgresql.jdbc2.AbstractJdbc2Array.getArray(AbstractJdbc2Array.java:110) at cz.admin24.shdb.db.DAO.SwitchportConfig.<init>(SwitchportConfig.java:46) at cz.admin24.shdb.db.DAO.AccessConfigDAOBean.getPortConfigFromDB(AccessConfigDAOBean.java:129) at cz.admin24.shdb.db.DAO.AccessConfigDAOBean.getAllRequestedUpdates(AccessConfigDAOBean.java:92) at cz.admin24.shdb.network.ciscoconf.AccessConfigurator.updateSwitchsports(AccessConfigurator.java:59) at cz.admin24.shdb.network.ciscoconf.App.doUpdate(App.java:38) at cz.admin24.shdb.network.ciscoconf.App.main(App.java:66) Caused by: java.io.IOException: Stream closed at sun.nio.cs.StreamEncoder.ensureOpen(StreamEncoder.java:26) at sun.nio.cs.StreamEncoder.flush(StreamEncoder.java:121) at java.io.OutputStreamWriter.flush(OutputStreamWriter.java:212) at org.postgresql.core.PGStream.flush(PGStream.java:507) at org.postgresql.core.v3.QueryExecutorImpl.sendSync(QueryExecutorImpl.java:1107) at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:256) ... 12 more -- Petr Prikryl ----------------------- petrprikryl@centrum.cz prikryl@admin24.cz www.admin24.cz
What does the server log say? --- Maciek Sakrejda | System Architect | Truviso 1065 E. Hillsdale Blvd., Suite 215 Foster City, CA 94404 (650) 242-3500 Main www.truviso.com On Fri, Sep 10, 2010 at 4:53 PM, Petr Prikryl <peter.prikryl@gmail.com> wrote: > Good day, > I'm trying to fetch Array in one row. SQL works well, but when I tried to > convert org.postgresql.jdbc4.Jdbc4Array to java Array : > allowedMAC = (List<byte[]>) mac.getArray(); > > I'm getting exception below. > This exception is maybe caused by closed connection by > org.springframework.jdbc.core.JdbcTemplate . > > I tried to find out, how to fetch this org.postgresql.jdbc4.Jdbc4Array > directly (I have much rows in result and a need to retrieve everything in > one question), but function is trying to connect do DB. > How should I fetch everything in one select, am I able to disable those > "re-question"? > Thanks a lot > PP > > > > > Sep 11, 2010 1:00:07 AM cz.admin24.shdb.db.DAO.SwitchportConfig <init> > SEVERE: null > org.postgresql.util.PSQLException: An I/O error occured while sending to the > backend. > at > org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:283) > at > org.postgresql.jdbc2.AbstractJdbc2Statement.execute(AbstractJdbc2Statement.java:479) > at > org.postgresql.jdbc2.AbstractJdbc2Statement.executeWithFlags(AbstractJdbc2Statement.java:367) > at > org.postgresql.jdbc2.TypeInfoCache.getArrayDelimiter(TypeInfoCache.java:335) > at > org.postgresql.jdbc2.AbstractJdbc2Array.buildArrayList(AbstractJdbc2Array.java:165) > at > org.postgresql.jdbc2.AbstractJdbc2Array.getArrayImpl(AbstractJdbc2Array.java:138) > at > org.postgresql.jdbc2.AbstractJdbc2Array.getArray(AbstractJdbc2Array.java:110) > at > cz.admin24.shdb.db.DAO.SwitchportConfig.<init>(SwitchportConfig.java:46) > at > cz.admin24.shdb.db.DAO.AccessConfigDAOBean.getPortConfigFromDB(AccessConfigDAOBean.java:129) > at > cz.admin24.shdb.db.DAO.AccessConfigDAOBean.getAllRequestedUpdates(AccessConfigDAOBean.java:92) > at > cz.admin24.shdb.network.ciscoconf.AccessConfigurator.updateSwitchsports(AccessConfigurator.java:59) > at cz.admin24.shdb.network.ciscoconf.App.doUpdate(App.java:38) > at cz.admin24.shdb.network.ciscoconf.App.main(App.java:66) > Caused by: java.io.IOException: Stream closed > at sun.nio.cs.StreamEncoder.ensureOpen(StreamEncoder.java:26) > at sun.nio.cs.StreamEncoder.flush(StreamEncoder.java:121) > at java.io.OutputStreamWriter.flush(OutputStreamWriter.java:212) > at org.postgresql.core.PGStream.flush(PGStream.java:507) > at > org.postgresql.core.v3.QueryExecutorImpl.sendSync(QueryExecutorImpl.java:1107) > at > org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:256) > ... 12 more > > -- > Petr Prikryl > ----------------------- > petrprikryl@centrum.cz > prikryl@admin24.cz > www.admin24.cz > > > -- > Sent via pgsql-jdbc mailing list (pgsql-jdbc@postgresql.org) > To make changes to your subscription: > http://www.postgresql.org/mailpref/pgsql-jdbc >
So, I found that JDBC needs some aditional information to determine delimiter (viva opensource drivers). But it is worst , that JDBC driver hasn't implemented Array<Bytea> and I must use workaround (using strings). PP On 09/11/2010 02:32 AM, Maciek Sakrejda wrote: > What does the server log say? > --- > Maciek Sakrejda | System Architect | Truviso > > 1065 E. Hillsdale Blvd., Suite 215 > Foster City, CA 94404 > (650) 242-3500 Main > www.truviso.com > > > > On Fri, Sep 10, 2010 at 4:53 PM, Petr Prikryl<peter.prikryl@gmail.com> wrote: > >> Good day, >> I'm trying to fetch Array in one row. SQL works well, but when I tried to >> convert org.postgresql.jdbc4.Jdbc4Array to java Array : >> allowedMAC = (List<byte[]>) mac.getArray(); >> >> I'm getting exception below. >> This exception is maybe caused by closed connection by >> org.springframework.jdbc.core.JdbcTemplate . >> >> I tried to find out, how to fetch this org.postgresql.jdbc4.Jdbc4Array >> directly (I have much rows in result and a need to retrieve everything in >> one question), but function is trying to connect do DB. >> How should I fetch everything in one select, am I able to disable those >> "re-question"? >> Thanks a lot >> PP >> >> >> >> >> Sep 11, 2010 1:00:07 AM cz.admin24.shdb.db.DAO.SwitchportConfig<init> >> SEVERE: null >> org.postgresql.util.PSQLException: An I/O error occured while sending to the >> backend. >> at >> org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:283) >> at >> org.postgresql.jdbc2.AbstractJdbc2Statement.execute(AbstractJdbc2Statement.java:479) >> at >> org.postgresql.jdbc2.AbstractJdbc2Statement.executeWithFlags(AbstractJdbc2Statement.java:367) >> at >> org.postgresql.jdbc2.TypeInfoCache.getArrayDelimiter(TypeInfoCache.java:335) >> at >> org.postgresql.jdbc2.AbstractJdbc2Array.buildArrayList(AbstractJdbc2Array.java:165) >> at >> org.postgresql.jdbc2.AbstractJdbc2Array.getArrayImpl(AbstractJdbc2Array.java:138) >> at >> org.postgresql.jdbc2.AbstractJdbc2Array.getArray(AbstractJdbc2Array.java:110) >> at >> cz.admin24.shdb.db.DAO.SwitchportConfig.<init>(SwitchportConfig.java:46) >> at >> cz.admin24.shdb.db.DAO.AccessConfigDAOBean.getPortConfigFromDB(AccessConfigDAOBean.java:129) >> at >> cz.admin24.shdb.db.DAO.AccessConfigDAOBean.getAllRequestedUpdates(AccessConfigDAOBean.java:92) >> at >> cz.admin24.shdb.network.ciscoconf.AccessConfigurator.updateSwitchsports(AccessConfigurator.java:59) >> at cz.admin24.shdb.network.ciscoconf.App.doUpdate(App.java:38) >> at cz.admin24.shdb.network.ciscoconf.App.main(App.java:66) >> Caused by: java.io.IOException: Stream closed >> at sun.nio.cs.StreamEncoder.ensureOpen(StreamEncoder.java:26) >> at sun.nio.cs.StreamEncoder.flush(StreamEncoder.java:121) >> at java.io.OutputStreamWriter.flush(OutputStreamWriter.java:212) >> at org.postgresql.core.PGStream.flush(PGStream.java:507) >> at >> org.postgresql.core.v3.QueryExecutorImpl.sendSync(QueryExecutorImpl.java:1107) >> at >> org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:256) >> ... 12 more >> >> -- >> Petr Prikryl >> ----------------------- >> petrprikryl@centrum.cz >> prikryl@admin24.cz >> www.admin24.cz >> >> >> -- >> Sent via pgsql-jdbc mailing list (pgsql-jdbc@postgresql.org) >> To make changes to your subscription: >> http://www.postgresql.org/mailpref/pgsql-jdbc >> >> -- Petr Prikryl ----------------------- petrprikryl@centrum.cz prikryl@admin24.cz www.admin24.cz
On Sat, 11 Sep 2010, Petr Prikryl wrote: > So, I found that JDBC needs some aditional information to determine delimiter > (viva opensource drivers). But it is worst , that JDBC driver hasn't > implemented Array<Bytea> and I must use workaround (using strings). > PP > I'm not sure what you're referring to with Array<Bytea>. I suppose we could return byte[][], that seems like a reasonable thing to do. Kris Jurka