private static boolean isClosedException(Throwable t) { if (!(t instanceof IOException)) { return false; } String message = t.getMessage(); if ((t.getCause() == null || t.getCause() == t) && message != null && (message.equals("Connection reset by peer") || message.equals("Broken pipe") || StringUtil.indexOfIgnoreCase(message, "closed") >= 0)) { //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ return true; } return false; }
@Override protected String getRuntimeType(int type, String typeName, int precision, int scale) { //overrides for varchar2 and nvarchar2 if (type == 12 || (type == Types.OTHER && typeName != null && StringUtil.indexOfIgnoreCase(typeName, "char") > -1)) { //$NON-NLS-1$ return TypeFacility.RUNTIME_NAMES.STRING; } if (useGeometryType && "SDO_GEOMETRY".equalsIgnoreCase(typeName)) { //$NON-NLS-1$ return TypeFacility.RUNTIME_NAMES.GEOMETRY; } return super.getRuntimeType(type, typeName, precision, scale); }
@Override public void initCapabilities(Connection connection) throws TranslatorException { super.initCapabilities(connection); if (!jtdsDriver && connection != null) { try { jtdsDriver = StringUtil.indexOfIgnoreCase(connection.getMetaData().getDriverName(), "jtds") != -1; //$NON-NLS-1$ } catch (SQLException e) { LogManager.logDetail(LogConstants.CTX_CONNECTOR, e, "Could not automatically determine if the jtds driver is in use"); //$NON-NLS-1$ } } handleTimeConversions(); }
@Test public void testIndexOfIgnoreCase() { String text = "test"; //$NON-NLS-1$ assertEquals(-1,StringUtil.indexOfIgnoreCase(null,text)); assertEquals(-1,StringUtil.indexOfIgnoreCase("",text)); //$NON-NLS-1$ assertEquals(-1,StringUtil.indexOfIgnoreCase(text,null)); assertEquals(-1,StringUtil.indexOfIgnoreCase(text,"")); //$NON-NLS-1$ assertEquals(-1,StringUtil.indexOfIgnoreCase(text,"testing")); //$NON-NLS-1$ assertEquals(1,StringUtil.indexOfIgnoreCase(text,"es")); //$NON-NLS-1$ assertEquals(1,StringUtil.indexOfIgnoreCase(text,"Es")); //$NON-NLS-1$ assertEquals(1,StringUtil.indexOfIgnoreCase(text,"eS")); //$NON-NLS-1$ assertEquals(2,StringUtil.indexOfIgnoreCase(text,"ST")); //$NON-NLS-1$ }
fks = metadata.getImportedKeys(tableInfo.catalog, tableInfo.schema, tableInfo.name); } catch (SQLException e) { if (tableInfo.type != null && StringUtil.indexOfIgnoreCase(tableInfo.type, "TABLE") < 0) { //$NON-NLS-1$ LogManager.logDetail(LogConstants.CTX_CONNECTOR, e, "skipping foreign keys for non-table", tableInfo.table.getFullName()); //$NON-NLS-1$ } else {
@Override public List<?> translate(Function function) { if (function.getParameters().get(0) instanceof ColumnReference) { ColumnReference cr = (ColumnReference)function.getParameters().get(0); String nativeType = cr.getMetadataObject().getNativeType(); if (nativeType != null && StringUtil.indexOfIgnoreCase(nativeType, "char") == -1) { //$NON-NLS-1$ Function cast = ConvertModifier.createConvertFunction(getLanguageFactory(), cr, (StringUtil.startsWithIgnoreCase(nativeType.trim(), "n")?"n":"")+"varchar(max)"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ cast.setName("cast"); //$NON-NLS-1$ function.getParameters().set(0, cast); } } return super.translate(function); } }