From: | David Goodenough <david(dot)goodenough(at)btconnect(dot)com> |
---|---|
To: | pgsql-jdbc(at)postgresql(dot)org |
Subject: | Using ResultSetMetaData.getColumnTypeName |
Date: | 2010-09-30 14:33:21 |
Message-ID: | 201009301533.21174.david.goodenough@btconnect.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-jdbc |
I am trying to write some code to copy the definition of a database with all
its tables and keys, and I am trying to do it in Java using JDBC. You may
think that I am mad and that there are better ways of doing this, but in this
case I am already within a Java app, and so using native facilities is more
trouble than it is worth.
The problem I have hit is that getColumnTypeName does not return say
numeric or int for a number, but a size specific name like int4. If you then
use int4 as the type you can not use the precision (it is implicit I guess)
in the column type. So you can say "fred int(10)" or "fred int4" but not
"fred int4(10)". So I guess my question is whether there is a simple way
to work out whether a given column type name is or is not allowed to be
followed by a precision.
I suppose I could use getColumnType and convert those into strings,
but then one has to ask why getColumnTypeName exists.
David
BTW, I tried googling to find some code to do this, and I found some
MySql specific code but nothing for Postgresql. If someone has already
done this I would much rather use tested code than reinvent the wheel.
From | Date | Subject | |
---|---|---|---|
Next Message | dmp | 2010-09-30 16:23:28 | Re: Using ResultSetMetaData.getColumnTypeName |
Previous Message | Craig Ringer | 2010-09-30 14:26:44 | Re: [BUGS] Mapping Hibernate boolean to smallint(Postgresql) |