Grokbase
Topics Posts Groups | in
x
[ help ]

. (a...@inicia.es)

Profile | Posts (3)

User Information

Display Name:.
Partial Email Address:a...@inicia.es
Posts:
3 total
3 in PostgreSQL - JDBC

3 Most Recent

1) . "text" type is java.sql.Types.varchar not longvarchar
| +1 vote
If you get the data type of a column defined as 'text', the driver maps this type to...
PostgreSQL - JDBC
[ Profile | Reply to group ] [ Flat  Thread  Threaded ]
If you get the data type of a column defined as 'text', the driver maps this
type to java.sql.Types.VARCHAR with a column size of '-1'.

It wouldn't be better if the 'text' type, that, as its name says is not a mere
'varchar', was mapped to java.sql.Types.LONGVARCHAR?

Looks like *no* PostgreSQL type that fit into this java type, so why do it this
way?



Manel
2) . Re: Problem asking columns allowing NULL values
| +1 vote
Oopss!!! Sorry, I was doing wrong! I was looking at the value of rsmeta.columnNullable, a *static*...
PostgreSQL - JDBC
[ Profile | Reply to group ] [ Flat  Thread  Threaded ]
> Can you send me a small test program to demonstrate the problem?
>
> Dave
> On Tue, 2003-04-08 at 13:23, Manel de la Rosa wrote:
> > Hello,
> > I'm trying to ask a PostgreSQL server, using its JDBC driver, if the
> > columns of a table allow NULL values. To do so, I look at the value of the
> > field columnNullable (class ResultSetMetaData). Simply put, if I have a
> > ResultSet"rs" filled with rows from a query, I do the following:
> >
> >
> >
> > ResultSetMetaData rsmeta = rs.getMetaData();
> >
> >    if (rsmeta.columnNullable == 1)
> >  System.out.printl("null values allowed");
> >    else
> > System.out.printl("null values NOT allowed");
> >
> >
> >
> > The result says that *all* columns allow NULL values, although I've defined
> > several of them with the clause "NOT NULL" (I've checked that this columns
> > does really not allow NULL values, trying INSERT statements with psql).
> >
> > I'm using the last stable release of the JDBC driver. Somebody else have
> > suffered the same problem? Or I'm doing something wrong? I'd be very
> > grateful if somebody could help me.
> >
>

Oopss!!!
Sorry, I was doing wrong! I was looking at the value of rsmeta.columnNullable,
a *static* variable, instead of calling to
ResultSetMetaData.isNullable(column). My fault.

But now that I'm doing right, surprise: *all* columns are found as
"columnNullableUnknown" by the JDBC driver. Looking at old mails of this list,
I've found a 2001 message describing the same problem, proposing a temporal
patch and saying this:

"This method is currently unimplemented and always returns
ResultSetMetaData.columnNullable. This is obviously incorrect
when a column is defined with NOT NULL or PRIMARY KEY. And we
have to think of check constraints, views, functions etc.

This patch simply changes the return value to
ResultSetMetaData.columnNullableUnknown. This is until someone
comes up with a real implementation of course."

I'll apreciate if somebody could tell me if someone are working on this. If
not, well, I'm not a Java guru, but perhaps I could help.

Thanks.
3) . Problem asking columns allowing NULL values
| +1 vote
Hello, I'm trying to ask a PostgreSQL server, using its JDBC driver, if the columns of a table...
PostgreSQL - JDBC
[ Profile | Reply to group ] [ Flat  Thread  Threaded ]
Hello,
I'm trying to ask a PostgreSQL server, using its JDBC driver, if the columns of
a table allow NULL values. To do so, I look at the value of the field
columnNullable (class ResultSetMetaData). Simply put, if I have a ResultSet
"rs" filled with rows from a query, I do the following:



ResultSetMetaData rsmeta = rs.getMetaData();

   if (rsmeta.columnNullable == 1)
System.out.printl("null values allowed");
   else
System.out.printl("null values NOT allowed");



The result says that *all* columns allow NULL values, although I've defined
several of them with the clause "NOT NULL" (I've checked that this columns does
really not allow NULL values, trying INSERT statements with psql).

I'm using the last stable release of the JDBC driver. Somebody else have
suffered the same problem? Or I'm doing something wrong? I'd be very grateful
if somebody could help me.

spacer
Profile | Posts (3)
Home > People > .