SQLData, PostgreSQL and typemap woes

Поиск
Список
Период
Сортировка
От jon@univits.se
Тема SQLData, PostgreSQL and typemap woes
Дата
Msg-id 3cx4e5vh.fsf@univits.se
обсуждение исходный текст
Список pgsql-general
Hi,

we're currently trying to evaluate PostgreSQL as an Object Storage, using the JDBC SQLData interface. We're using the
PostgreSQLprovided tutorial UDT Complex and we're trying to instantiate a Java Complex class with it.  
Here's what we're trying to do:

java.util.Map map = dbConnection.getTypeMap();
map.put("complex",
Class.forName("Complex"));
dbConnection.setTypeMap(map);

map = dbConnection.getTypeMap();

Statement stmt = dbConnection.createStatement();
ResultSet rs = stmt.executeQuery("SELECT cp FROM complex_test WHERE id=1");
rs.next();
ResultSetMetaData metaData = rs.getMetaData();
System.out.println("Type from SQL: " + metaData.getColumnTypeName(1));

Object foo = rs.getObject(1);

if (foo instanceof Complex) {
Complex cp = (Complex)foo;
System.out.println("Got: " + cp + " from DB");
}
else {
System.out.println("Class name: " + foo.getClass().getName());
System.out.println("Got " + foo);
}
stmt.close();

The above mentioned code always returns a java.lang.String instance, which makes us believe that the type map is
incorrect. 

The name of the logical database is 'server', the table name is 'complex_test'. Here's the table definition:
server=# \d complex_test
Table "complex_test"
Column | Type | Modifiers
--------+---------+-----------
id | integer |
cp | complex |

server=# select * from complex_test;
id | cp
----+---------
1 | (55,33)

We're using jxDBCon (http://sourceforge.net/projects/jxdbcon) PostgreSQL
JDBC driver.

Cheers,
Jon & Jens

В списке pgsql-general по дате отправления:

Предыдущее
От: "Bertin, Philippe"
Дата:
Сообщение: Re: IF- statements in a rule's 'DO INSTEAD SELECT ...'- statement
Следующее
От: "Andrey Y. Mosienko"
Дата:
Сообщение: How to get description of table field in trigger