01: /*
02: * Copyright 2002 (C) TJDO.
03: * All rights reserved.
04: *
05: * This software is distributed under the terms of the TJDO License version 1.0.
06: * See the terms of the TJDO License in the documentation provided with this software.
07: *
08: * $Id: PostgreSQLColumnInfo.java,v 1.2 2004/03/22 04:58:13 jackknifebarber Exp $
09: */
10:
11: package com.triactive.jdo.store;
12:
13: import java.sql.ResultSet;
14: import java.sql.Types;
15:
16: /**
17: * Represents the metadata of a specific table column in PostgreSQL.
18: *
19: * @author <a href="mailto:mmartin5@austin.rr.com">Mike Martin</a>
20: * @version $Revision: 1.2 $
21: */
22:
23: class PostgreSQLColumnInfo extends ColumnInfo {
24: /**
25: * Constructs a column information object from the current row of the given
26: * result set. The {@link ResultSet} object passed must have been obtained
27: * from a call to DatabaseMetaData.getColumns().
28: *
29: * <p>This method only retrieves the values from the current row; the caller
30: * is required to advance to the next row with {@link ResultSet#next}.
31: *
32: * @param rs The result set returned from DatabaseMetaData.getColumns().
33: */
34:
35: public PostgreSQLColumnInfo(ResultSet rs) {
36: super (rs);
37:
38: if (typeName.equalsIgnoreCase("text"))
39: dataType = Types.LONGVARCHAR;
40: else if (typeName.equalsIgnoreCase("bytea"))
41: dataType = Types.LONGVARBINARY;
42:
43: /*
44: * The PostgreSQL drivers sometimes produce some truly funky metadata.
45: * I saw these next two occur during unit testing when
46: * decimal_widget.big_decimal_field reported a columnSize of 65535 and
47: * a decimalDigits of 65534, instead of the correct answers of 18 and 2.
48: *
49: * A -1 for either of these will cause their validation to be bypassed,
50: * which is a shame but it's all we can do. No one should be surprised
51: * if we end up needing more of these.
52: */
53: if (columnSize > PostgreSQLTypeInfo.MAX_PRECISION)
54: columnSize = -1;
55:
56: if (decimalDigits > PostgreSQLTypeInfo.MAX_PRECISION)
57: decimalDigits = -1;
58: }
59: }
|