This is a discussion on reading an oidvector field error within the pgsql Interfaces jdbc forums, part of the PostgreSQL category; --> Hi: I need to read from the database a oidvector field, I'm using this code snipped to do this: ...
| |||||||
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| ||||
| Hi: I need to read from the database a oidvector field, I'm using this code snipped to do this: Array argsList = rsFunc.getArray("field"); ResultSet rsArgs = argsList.getResultSet(); while (rsArgs.next()) { String s = rsArgs.getInt(2); //get an error here. PgDataType type = this.getDataType(s); args.add(type); } rsFunc: is the ResultSet to read the data. argsList: is and java.sql.Array. but I get an error of execution time on the line signed, I'm check the driver source code and I find that this kind of vector is not supported and I can't change the data type of the field. Could some one help me to solve this. -- My regards, Takeichi Kanzaki Cabrera Profesor of Computer Programming Techniques and Database Systems University of Holguin Cuba ---------------------------(end of broadcast)--------------------------- TIP 1: if posting/reading through Usenet, please send an appropriate subscribe-nomail command to majordomo@postgresql.org so that your message can get through to the mailing list cleanly |
| |||
| Takeichi Kanzaki Cabrera wrote: > but I get an error of execution time on the line signed, What is the exact error that you get? -O ---------------------------(end of broadcast)--------------------------- TIP 4: Have you searched our list archives? http://archives.postgresql.org |
| |||
| Here is the exception and the stack trace that I get: org.postgresql.util.PSQLException: Method org.postgresql.jdbc3.Jdbc3Array.getArrayImpl(long, int,Map) is not yet implemented. at org.postgresql.Driver.notImplemented(Driver.java:5 80) at org.postgresql.jdbc2.AbstractJdbc2Array.getArrayIm pl(AbstractJdbc2Array.java:232) at org.postgresql.jdbc2.AbstractJdbc2Array.getResultS etImpl(AbstractJdbc2Array.java:291) at org.postgresql.jdbc2.AbstractJdbc2Array.getResultS et(AbstractJdbc2Array.java:252) at pgObjects.PgDatabase.loadFunctionsFromDatabase(PgD atabase.java:893) at test.Test.showFunctions(Test.java:134) at test.Test.main(Test.java:166) Takeichi. ---------------------------(end of broadcast)--------------------------- TIP 5: don't forget to increase your free space map settings |
| |||
| Takeichi Kanzaki Cabrera wrote: > Here is the exception and the stack trace that I get: > org.postgresql.util.PSQLException: Method > org.postgresql.jdbc3.Jdbc3Array.getArrayImpl(long, int,Map) is not yet > implemented. > at org.postgresql.Driver.notImplemented(Driver.java:5 80) > at org.postgresql.jdbc2.AbstractJdbc2Array.getArrayIm pl(AbstractJdbc2Array.java:232) > at org.postgresql.jdbc2.AbstractJdbc2Array.getResultS etImpl(AbstractJdbc2Array.java:291) > at org.postgresql.jdbc2.AbstractJdbc2Array.getResultS et(AbstractJdbc2Array.java:252) > at pgObjects.PgDatabase.loadFunctionsFromDatabase(PgD atabase.java:893) This stacktrace doesn't match the line in your code you claim throws an exception. You originally said: > Array argsList = rsFunc.getArray("field"); > ResultSet rsArgs = argsList.getResultSet(); > while (rsArgs.next()) { > String s = rsArgs.getInt(2); //get an error here. > PgDataType type = this.getDataType(s); > args.add(type); > } but the code path your stacktrace shows is throwing an exception on getResultSet(). Can you clarify what the code that actually causes the error is? However the most likely cause is that the array code just does not understand the OID type -- there is this code in getArrayImpl when an unsupported array element type is encountered: >> default: >> if (conn.getLogger().logDebug()) >> conn.getLogger().debug("getArrayImpl(long,int,Map) with "+getBaseTypeName()); >> throw org.postgresql.Driver.notImplemented(this.getClass (), "getArrayImpl(long,int,Map)"); (this should really throw a more informative exception..) You could use getString() and parse the array representation yourself as a workaround, or teach the driver's array code about oids. -O ---------------------------(end of broadcast)--------------------------- TIP 9: In versions below 8.0, the planner will ignore your desire to choose an index scan if your joining column's datatypes do not match |
| |||
| Oliver Jowett <oliver@opencloud.com> writes: > However the most likely cause is that the array code just does not > understand the OID type -- there is this code in getArrayImpl when an > unsupported array element type is encountered: Another problem is that oidvector is not the same as oid[] --- for what are now entirely historical reasons, they have different external representations, which is certainly going to confuse any client-side code trying to parse the data. You'd really need some single-purpose code in the driver to handle oidvector at all. In very recent PG releases, you could cast oidvector to oid[] (or maybe better int8[]) in your query, but unless the JDBC array code copes with nondefault subscripts, it'll still have trouble: regression=# select '1 2 3': int8 --------------- [0:2]={1,2,3} (1 row) regression=# regards, tom lane ---------------------------(end of broadcast)--------------------------- TIP 5: don't forget to increase your free space map settings |
| |||
| On Mon, 16 Jan 2006, Tom Lane wrote: > In very recent PG releases, you could cast oidvector to oid[] (or maybe > better int8[]) in your query, but unless the JDBC array code copes with > nondefault subscripts, it'll still have trouble: > The JDBC array code throws away nondefault subscripts because the JDBC spec says that all arrays are 1-indexed. For the most part people don't want non-default subscripts and only get them via prepending operations that they didn't expect to alter the indexing (of course these are now gone in 8.2). Kris Jurka ---------------------------(end of broadcast)--------------------------- TIP 4: Have you searched our list archives? http://archives.postgresql.org |
| ||||
| Kris Jurka <books@ejurka.com> writes: > On Mon, 16 Jan 2006, Tom Lane wrote: >> In very recent PG releases, you could cast oidvector to oid[] (or maybe >> better int8[]) in your query, but unless the JDBC array code copes with >> nondefault subscripts, it'll still have trouble: > The JDBC array code throws away nondefault subscripts because the JDBC > spec says that all arrays are 1-indexed. OK, so casting to int8[] in the query should be a usable workaround. (You want int8 not int4 because OIDs are unsigned and won't necessarily fit in an int4.) regards, tom lane ---------------------------(end of broadcast)--------------------------- TIP 3: Have you checked our extensive FAQ? http://www.postgresql.org/docs/faq |