Problem asking columns allowing NULL values

From: (dot) <alzina(at)inicia(dot)es>
To: pgsql-jdbc(at)postgresql(dot)org
Subject: Problem asking columns allowing NULL values
Date: 2003-04-08 17:23:00
Message-ID: 20030408192300.6d1e73bb.alzina@inicia.es
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-jdbc

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.

Responses

Browse pgsql-jdbc by date

  From Date Subject
Next Message Sohail A. Khan 2003-04-08 17:44:58 JDBC
Previous Message Todd Cornett 2003-04-08 17:17:02 Bug in getImportedExportedKeys(), DatabaseMetaData class