int typeOid = (int) rs.getLong("atttypid"); int typeMod = rs.getInt("atttypmod"); int decimalDigits = connection.getTypeInfo().getScale(typeOid, typeMod); int columnSize = connection.getTypeInfo().getPrecision(typeOid, typeMod); if (columnSize == 0) { columnSize = connection.getTypeInfo().getDisplaySize(typeOid, typeMod); connection.encodeString(Integer.toString(connection.getTypeInfo().getSQLType(typeOid))); tuple[3] = connection.encodeString(connection.getTypeInfo().getPGType(typeOid)); tuple[4] = connection.encodeString(Integer.toString(columnSize)); tuple[5] = null; // unused
for (Iterator<String> i = connection.getTypeInfo().getPGTypeNamesWithSQLTypes(); i.hasNext(); ) { String pgType = i.next(); int sqlType = connection.getTypeInfo().getSQLType(pgType); sqlwhen.append(" when typname = ").append(escapeQuotes(pgType)).append(" then ").append(sqlType);
public AbstractJdbc3gConnection(String host, int port, String user, String database, Properties info, String url) throws SQLException { super(host, port, user, database, info, url); TypeInfo types = getTypeInfo(); if (haveMinimumServerVersion("8.3")) { types.addCoreType("uuid", Oid.UUID, java.sql.Types.OTHER, "java.util.UUID", Oid.UUID_ARRAY); } }
/** * * @return the default length of the type */ public int getDefaultLength() { if (typeInfo == null) { return TypeRegistry.UNKNOWN_LENGTH; } int size = typeInfo.getPrecision(oid, TypeRegistry.NO_TYPE_MODIFIER); if (size == 0) { size = typeInfo.getDisplaySize(oid, TypeRegistry.NO_TYPE_MODIFIER); } return size; }
private void initSqlType(Field field) throws SQLException { if (field.isTypeInitialized()) { return; } TypeInfo typeInfo = connection.getTypeInfo(); int oid = field.getOID(); String pgType = typeInfo.getPGType(oid); int sqlType = typeInfo.getSQLType(pgType); field.setSQLType(sqlType); field.setPGType(pgType); }
tuple[1] = connection.encodeString(Integer.toString(connection.getTypeInfo().getSQLType(typname))); tuple[2] = connection.encodeString(Integer.toString(connection.getTypeInfo().getMaximumPrecision(typeOid))); if (connection.getTypeInfo().requiresQuoting(typeOid)) tuple[7] = connection.getTypeInfo().isCaseSensitive(typeOid) ? bt : bf; tuple[8] = bSearchable; // any thing can be used in the WHERE clause tuple[9] = connection.getTypeInfo().isSigned(typeOid) ? bf : bt; tuple[10] = bf; // false for now - must handle money tuple[11] = bf; // false - it isn't autoincrement
public int getSqlType(String typeName) throws SQLException { boolean isCoreType = preloadedSqlTypes.contains(typeName); // obtain core types such as bool, int2 etc. from the driver, as it correctly maps these types to the JDBC // type codes. Also those values are cached in TypeInfoCache. if (isCoreType) { return typeInfo.getSQLType(typeName); } if (typeName.endsWith("[]")) { return Types.ARRAY; } // get custom type mappings from the map which was built up with a single query else { try { return sqlTypesByPgTypeNames.get(typeName); } catch(Exception e) { LOGGER.warn("Failed to obtain SQL type information for type {} via custom statement, falling back to TypeInfo#getSQLType()", typeName, e); return typeInfo.getSQLType(typeName); } } }
int sqlType = connection.getTypeInfo().getSQLType(typname); tuple[1] = connection.encodeString(Integer.toString(sqlType)); tuple[2] = connection .encodeString(Integer.toString(connection.getTypeInfo().getMaximumPrecision(typeOid))); if (connection.getTypeInfo().requiresQuotingSqlType(sqlType)) { tuple[3] = bliteral; tuple[4] = bliteral; tuple[7] = connection.getTypeInfo().isCaseSensitive(typeOid) ? bt : bf; tuple[8] = bSearchable; // any thing can be used in the WHERE clause tuple[9] = connection.getTypeInfo().isSigned(typeOid) ? bf : bt; tuple[10] = bf; // false for now - must handle money tuple[11] = bf; // false - it isn't autoincrement
final int type = connection.getTypeInfo().getSQLType(connection.getTypeInfo().getPGArrayElement(oid));
/** * * @return the default scale of the type */ public int getDefaultScale() { if (typeInfo == null) { return TypeRegistry.UNKNOWN_LENGTH; } return typeInfo.getScale(oid, TypeRegistry.NO_TYPE_MODIFIER); }
/** * Convert array list to PG String representation (e.g. {0,1,2}). */ private String toString(PgArrayList list) throws SQLException { StringBuffer b = new StringBuffer().append('{'); char delim = connection.getTypeInfo().getArrayDelimiter(oid); for (int i = 0; i < list.size(); i++) { Object v = list.get(i); if (i > 0) b.append(delim); if (v == null) b.append("NULL"); else if (v instanceof PgArrayList) b.append(toString((PgArrayList) v)); else escapeArrayElement(b, (String)v); } b.append('}'); return b.toString(); }
/** * @param modifier - type modifier coming from decoder * @return length of the type based on the modifier */ public int length(int modifier) { if (typeInfo == null) { return TypeRegistry.UNKNOWN_LENGTH; } switch (oid) { case Oid.TIMESTAMP: case Oid.TIMESTAMPTZ: case Oid.TIME: case Oid.TIMETZ: case Oid.INTERVAL: return typeInfo.getPrecision(oid, modifier); } return modifier; }
public String getParameterClassName(int param) throws SQLException { checkParamIndex(param); return _connection.getTypeInfo().getJavaClass(_oids[param - 1]); }
@Override public Array createArrayOf(String typeName, Object[] elements) throws SQLException { checkClosed(); int oid = getTypeInfo().getPGArrayType(typeName); if (oid == Oid.UNSPECIFIED) { throw new PSQLException( GT.tr("Unable to find server array type for provided name {0}.", typeName), PSQLState.INVALID_NAME); } if (elements == null) { return makeArray(oid, null); } char delim = getTypeInfo().getArrayDelimiter(oid); StringBuilder sb = new StringBuilder(); appendArray(sb, elements, delim); return makeArray(oid, sb.toString()); }
public int getColumnDisplaySize(int column) throws SQLException { Field field = getField(column); return connection.getTypeInfo().getDisplaySize(field.getOID(), field.getMod()); }
@Override public void addDataType(String type, Class<? extends PGobject> klass) throws SQLException { checkClosed(); _typeCache.addDataType(type, klass); }
private SqlTypeMapper(Connection db, TypeInfo typeInfo) throws SQLException { this.typeInfo = typeInfo; this.preloadedSqlTypes = Collect.unmodifiableSet(typeInfo.getPGTypeNamesWithSQLTypes()); this.sqlTypesByPgTypeNames = getSqlTypes(db, typeInfo); }
tuple[1] = connection.encodeString(Integer.toString(connection.getTypeInfo().getSQLType(typname))); tuple[2] = connection.encodeString(Integer.toString(connection.getTypeInfo().getMaximumPrecision(typeOid))); if (connection.getTypeInfo().requiresQuoting(typeOid)) tuple[7] = connection.getTypeInfo().isCaseSensitive(typeOid) ? bt : bf; tuple[8] = bSearchable; // any thing can be used in the WHERE clause tuple[9] = connection.getTypeInfo().isSigned(typeOid) ? bf : bt; tuple[10] = bf; // false for now - must handle money tuple[11] = bf; // false - it isn't autoincrement
public int getParameterType(int param) throws SQLException { checkParamIndex(param); return _connection.getTypeInfo().getSQLType(_oids[param - 1]); }
.encodeString(Integer.toString(java.sql.DatabaseMetaData.procedureColumnReturn)); tuple[5] = connection .encodeString(Integer.toString(connection.getTypeInfo().getSQLType(returnType))); tuple[6] = connection.encodeString(connection.getTypeInfo().getPGType(returnType)); tuple[7] = null; tuple[8] = null; connection.encodeString(Integer.toString(connection.getTypeInfo().getSQLType(argOid))); tuple[6] = connection.encodeString(connection.getTypeInfo().getPGType(argOid)); tuple[7] = null; tuple[8] = null; .encodeString(Integer.toString(java.sql.DatabaseMetaData.procedureColumnResult)); tuple[5] = connection .encodeString(Integer.toString(connection.getTypeInfo().getSQLType(columnTypeOid))); tuple[6] = connection.encodeString(connection.getTypeInfo().getPGType(columnTypeOid)); tuple[7] = null; tuple[8] = null;