當前位置: 首頁>>代碼示例>>Java>>正文


Java SQLDataException類代碼示例

本文整理匯總了Java中java.sql.SQLDataException的典型用法代碼示例。如果您正苦於以下問題:Java SQLDataException類的具體用法?Java SQLDataException怎麽用?Java SQLDataException使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


SQLDataException類屬於java.sql包,在下文中一共展示了SQLDataException類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: test_Constructor_LStringLStringILThrowable_20

import java.sql.SQLDataException; //導入依賴的package包/類
/**
 * @test java.sql.SQLDataException(String, String, int, Throwable)
 */
public void test_Constructor_LStringLStringILThrowable_20() {
    Throwable cause = new Exception("MYTHROWABLE");
    SQLDataException sQLDataException = new SQLDataException(null, null, 0,
            cause);
    assertNotNull(sQLDataException);
    assertNull("The SQLState of SQLDataException should be null",
            sQLDataException.getSQLState());
    assertNull("The reason of SQLDataException should be null",
            sQLDataException.getMessage());
    assertEquals("The error code of SQLDataException should be 0",
            sQLDataException.getErrorCode(), 0);
    assertEquals(
            "The cause of SQLDataException set and get should be equivalent",
            cause, sQLDataException.getCause());
}
 
開發者ID:shannah,項目名稱:cn1,代碼行數:19,代碼來源:SQLDataExceptionTest.java

示例2: test12

import java.sql.SQLDataException; //導入依賴的package包/類
/**
 * Validate that the ordering of the returned Exceptions is correct
 * using traditional while loop
 */
@Test
public void test12() {
    SQLDataException ex = new SQLDataException("Exception 1", t1);
    SQLDataException ex1 = new SQLDataException("Exception 2");
    SQLDataException ex2 = new SQLDataException("Exception 3", t2);
    ex.setNextException(ex1);
    ex.setNextException(ex2);
    int num = 0;
    SQLException sqe = ex;
    while (sqe != null) {
        assertTrue(msgs[num++].equals(sqe.getMessage()));
        Throwable c = sqe.getCause();
        while (c != null) {
            assertTrue(msgs[num++].equals(c.getMessage()));
            c = c.getCause();
        }
        sqe = sqe.getNextException();
    }
}
 
開發者ID:lambdalab-mirror,項目名稱:jdk8u-jdk,代碼行數:24,代碼來源:SQLDataExceptionTests.java

示例3: testGetBinaryStream

import java.sql.SQLDataException; //導入依賴的package包/類
public void testGetBinaryStream(ResultSet resultSet) throws SQLException {
  try {
    resultSet.getBinaryStream(ordinal);
    fail("Was expecting to throw SQLDataException");
  } catch (Exception e) {
    assertThat(e, isA((Class) SQLDataException.class)); // success
  }
}
 
開發者ID:apache,項目名稱:calcite-avatica,代碼行數:9,代碼來源:AvaticaResultSetConversionsTest.java

示例4: testGetDate

import java.sql.SQLDataException; //導入依賴的package包/類
public void testGetDate(ResultSet resultSet, Calendar calendar) throws SQLException {
  try {
    resultSet.getDate(ordinal, calendar);
    fail("Was expecting to throw SQLDataException");
  } catch (Exception e) {
    assertThat(e, isA((Class) SQLDataException.class)); // success
  }
}
 
開發者ID:apache,項目名稱:calcite-avatica,代碼行數:9,代碼來源:AvaticaResultSetConversionsTest.java

示例5: testGetNClob

import java.sql.SQLDataException; //導入依賴的package包/類
public void testGetNClob(ResultSet resultSet) throws SQLException {
  try {
    resultSet.getNClob(ordinal);
    fail("Was expecting to throw SQLDataException");
  } catch (Exception e) {
    assertThat(e, isA((Class) SQLDataException.class)); // success
  }
}
 
開發者ID:apache,項目名稱:calcite-avatica,代碼行數:9,代碼來源:AvaticaResultSetConversionsTest.java

示例6: modIn

import java.sql.SQLDataException; //導入依賴的package包/類
/**
 * Type modifier input function for IntWithMod type: accepts
 * "even" or "odd". The modifier value is 0 for even or 1 for odd.
 */
@Function(schema="javatest", name="intwithmod_typmodin",
	provides="IntWithMod modIn",
	effects=IMMUTABLE, onNullInput=RETURNS_NULL)
public static int modIn(@SQLType("cstring[]") String[] toks)
	throws SQLException {
	if ( 1 != toks.length )
		throw new SQLDataException(
			"only one type modifier allowed for IntWithMod", "22023");
	if ( "even".equalsIgnoreCase(toks[0]) )
		return 0;
	if ( "odd".equalsIgnoreCase(toks[0]) )
		return 1;
	throw new SQLDataException(
		"modifier for IntWithMod must be \"even\" or \"odd\"", "22023");
}
 
開發者ID:greenplum-db,項目名稱:pljava,代碼行數:20,代碼來源:IntWithMod.java

示例7: modApply

import java.sql.SQLDataException; //導入依賴的package包/類
/**
 * Function backing the type-modifier application cast for IntWithMod type.
 */
@Function(schema="javatest", name="intwithmod_typmodapply",
	requires="IntWithMod type", provides="IntWithMod modApply",
	type="javatest.IntWithMod", effects=IMMUTABLE, onNullInput=RETURNS_NULL)
public static IntWithMod modApply(
	@SQLType("javatest.IntWithMod") IntWithMod iwm,
	int mod, boolean explicit) throws SQLException {

	if ( -1 == mod )
		return iwm;
	if ( (iwm.m_value & 1) != mod )
		throw new SQLDataException(
			"invalid value " + iwm + " for " +
			iwm.getSQLTypeName() + modOut(mod), "22000");
	iwm.m_typeName += modOut(mod);
	return iwm;
}
 
開發者ID:greenplum-db,項目名稱:pljava,代碼行數:20,代碼來源:IntWithMod.java

示例8: validateDateTime

import java.sql.SQLDataException; //導入依賴的package包/類
private static String validateDateTime(Object value, boolean timestampTz) throws SQLDataException {
    if (value instanceof Number) {
        return AtsdMeta.TIMESTAMP_PRINTER.format(((Number) value).longValue());
    } else if (!(value instanceof String)) {
        throw new SQLDataException("Invalid value: " + value + ". Current type: " + value.getClass().getSimpleName()
                + ", expected type: " + Timestamp.class.getSimpleName());
    }
    final String dateTime = value.toString();
    Matcher matcher = DATETIME_ISO_PATTERN.matcher(dateTime);
    if (matcher.matches()) {
        return dateTime;
    }
    matcher = TIMESTAMP_PATTERN.matcher(dateTime);
    if (matcher.matches()) {
        final Timestamp timestamp = Timestamp.valueOf(dateTime);
        final Calendar calendar = Calendar.getInstance();
        calendar.setTimeInMillis(timestamp.getTime());
        if (timestampTz) {
            calendar.set(Calendar.ZONE_OFFSET, 0);
            calendar.set(Calendar.DST_OFFSET, 0);
        }
        return ISO8601Utils.format(calendar.getTime(), true);
    }
    throw new SQLDataException("Invalid datetime value: " + value + ". Expected formats: yyyy-MM-dd'T'HH:mm:ss[.SSS]'Z', yyyy-MM-dd HH:mm:ss[.fffffffff]");
}
 
開發者ID:axibase,項目名稱:atsd-jdbc,代碼行數:26,代碼來源:AtsdSqlConverter.java

示例9: parseTags

import java.sql.SQLDataException; //導入依賴的package包/類
private static Map<String, String> parseTags(String value) throws SQLDataException {
    if (StringUtils.isBlank(value)) {
        return Collections.emptyMap();
    }

    String[] tags = StringUtils.split(value, TAGS_DELIMETER);
    Map<String, String> result = new LinkedHashMap<>();
    Pair<String, String> nameAndValue;
    for (String tag : tags) {
        nameAndValue = parseTag(StringUtils.trim(tag));
        if (nameAndValue != null) {
            result.put(nameAndValue.getKey(), nameAndValue.getValue());
        }
    }
    return result;
}
 
開發者ID:axibase,項目名稱:atsd-jdbc,代碼行數:17,代碼來源:AtsdSqlConverter.java

示例10: unboxException

import java.sql.SQLDataException; //導入依賴的package包/類
public static SQLException unboxException(SQLException exception) {
	final Throwable cause = exception.getCause();
	if (cause instanceof SQLDataException) {
		return (SQLDataException) cause;
	} else if (cause instanceof SQLFeatureNotSupportedException) {
		return (SQLFeatureNotSupportedException) cause;
	} else if (!(cause instanceof RuntimeException)) {
		return exception;
	}
	Throwable finalCause = exception;
	if (cause instanceof AtsdRuntimeException) {
		Throwable inner = cause.getCause();
		if (inner instanceof SQLException) { // parsed result from ATSD
			finalCause = cause;
		}
	}

	if (isMetricNotFoundException(cause.getMessage())) {
		return new AtsdMetricNotFoundException(exception.getMessage(), finalCause);
	} else {
		return new SQLException(exception.getMessage(), finalCause);
	}
}
 
開發者ID:axibase,項目名稱:atsd-jdbc,代碼行數:24,代碼來源:ExceptionsUtil.java

示例11: extractSingleRow

import java.sql.SQLDataException; //導入依賴的package包/類
private Object extractSingleRow(ResultSetIterator iterator) throws SQLException {
    if (!iterator.hasNext()) {
        return null;
    }

    Map<String, Object> row = iterator.next();
    if (iterator.hasNext()) {
        throw new SQLDataException("Query result not unique for outputType=SelectOne.");
    } else if (getEndpoint().getOutputClass() != null) {
        return newBeanInstance(row);
    } else if (row.size() == 1) {
        return row.values().iterator().next();
    } else {
        return row;
    }
}
 
開發者ID:HydAu,項目名稱:Camel,代碼行數:17,代碼來源:JdbcProducer.java

示例12: initDataset

import java.sql.SQLDataException; //導入依賴的package包/類
/**
 * Generates Strings for RecyclerView's adapter. This data would usually come
 * from a local content provider or remote server.
 */
private void initDataset(Context ctx) {
    datasource = new SoulissDBTagHelper(ctx);
    SoulissDBHelper.open();

    try {
        collectedTag = datasource.getTag(tagId);
    } catch (SQLDataException e) {
        Log.e(Constants.TAG, "CANT LOAD tagId" + tagId);
    }
    Log.i(Constants.TAG, "initDataset loaded TAG" + tagId + " with father ID: " + collectedTag.getFatherId());

    if (!opzioni.isDbConfigured())
        AlertDialogHelper.dbNotInitedDialog(ctx);

}
 
開發者ID:souliss,項目名稱:soulissapp,代碼行數:20,代碼來源:TagDetailFragment.java

示例13: onOptionsItemSelected

import java.sql.SQLDataException; //導入依賴的package包/類
@Override
public boolean onOptionsItemSelected(MenuItem item) {
    int id = item.getItemId();
    switch (id) {
        case R.id.aggiungiFiglio:
            long nuovoFiglioId = datasource.createOrUpdateTag(null);

            try {
                SoulissTag figlio = datasource.getTag(nuovoFiglioId);
                figlio.setFatherId(collectedTag.getTagId());
                collectedTag.getChildTags().add(figlio);
                datasource.createOrUpdateTag(collectedTag);
            } catch (SQLDataException e) {
                e.printStackTrace();
            }
            parallaxExtAdapter.notifyItemInserted(collectedTag.getChildTags().size() - 1);
            return true;
    }
    //home e altro nel activity
    return getActivity().onOptionsItemSelected(item);
}
 
開發者ID:souliss,項目名稱:soulissapp,代碼行數:22,代碼來源:TagDetailFragment.java

示例14: getTagsByTypicals

import java.sql.SQLDataException; //導入依賴的package包/類
public List<SoulissTag> getTagsByTypicals(SoulissTypical parent) {

        List<SoulissTag> comments = new ArrayList<>();
        String MY_QUERY = "SELECT * FROM " + SoulissDBOpenHelper.TABLE_TAGS_TYPICALS + " a "
                + " WHERE a." + SoulissDBOpenHelper.COLUMN_TAG_TYP_NODE_ID + " = " + parent.getNodeId()
                + " AND a." + SoulissDBOpenHelper.COLUMN_TAG_TYP_SLOT + " =  " + parent.getSlot();
        Cursor cursor = database.rawQuery(MY_QUERY, null);

        cursor.moveToFirst();
        while (!cursor.isAfterLast()) {
            int tagId = cursor.getInt(cursor.getColumnIndex(SoulissDBOpenHelper.COLUMN_TAG_TYP_TAG_ID));
            try {
                SoulissTag newTag = getTag(tagId);
                if (!comments.contains(newTag))
                    comments.add(newTag);
            } catch (SQLDataException e) {
                e.printStackTrace();
            }

            cursor.moveToNext();
        }
        // Make sure to close the cursor
        cursor.close();
        return comments;
    }
 
開發者ID:souliss,項目名稱:soulissapp,代碼行數:26,代碼來源:SoulissDBTagHelper.java

示例15: getQueries

import java.sql.SQLDataException; //導入依賴的package包/類
public List<String> getQueries() throws SQLDataException {
    CharStream input = new ANTLRInputStream(sqlWithPlaceholders);
    ANTLRErrorListener errorListener = new InternalErrorListener();
    ParametersLexer parametersLexer = new ParametersLexer(input);
    parametersLexer.removeErrorListeners();
    parametersLexer.addErrorListener(errorListener);
    CommonTokenStream commonTokenStream = new CommonTokenStream(parametersLexer);
    ParametersParser parametersParser = new ParametersParser(commonTokenStream);
    parametersParser.removeErrorListeners();
    parametersParser.addErrorListener(errorListener);
    ParseTree parseTree = parametersParser.queries();
    ParseTreeWalker walker = new ParseTreeWalker();
    walker.walk(this, parseTree);
    if (exception.isPresent()) {
        throw exception.get();
    }
    return preparedQueries;
}
 
開發者ID:meridor,項目名稱:perspective-backend,代碼行數:19,代碼來源:PlaceholderConfigurer.java


注:本文中的java.sql.SQLDataException類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。