微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

java.sql.SQLDataException的实例源码

项目:cn1    文件sqlDataExceptionTest.java   
/**
 * @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,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());
}
项目:jdk8u-jdk    文件sqlDataExceptionTests.java   
/**
 * 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();
    }
}
项目:openjdk-jdk10    文件sqlDataExceptionTests.java   
/**
 * Validate that the ordering of the returned Exceptions is correct
 * using Traditional while loop
 */
@Test
public void test12() {
    sqlDataException ex = new sqlDataException("Exception 1",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();
    }
}
项目:calcite-avatica    文件AvaticaResultSetConversionsTest.java   
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
  }
}
项目:calcite-avatica    文件AvaticaResultSetConversionsTest.java   
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
  }
}
项目:openjdk9    文件sqlDataExceptionTests.java   
/**
 * Validate that the ordering of the returned Exceptions is correct
 * using Traditional while loop
 */
@Test
public void test12() {
    sqlDataException ex = new sqlDataException("Exception 1",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();
    }
}
项目:jdk8u_jdk    文件sqlDataExceptionTests.java   
/**
 * Validate that the ordering of the returned Exceptions is correct
 * using Traditional while loop
 */
@Test
public void test12() {
    sqlDataException ex = new sqlDataException("Exception 1",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();
    }
}
项目:lookaside_java-1.8.0-openjdk    文件sqlDataExceptionTests.java   
/**
 * Validate that the ordering of the returned Exceptions is correct
 * using Traditional while loop
 */
@Test
public void test12() {
    sqlDataException ex = new sqlDataException("Exception 1",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();
    }
}
项目:pljava    文件IntWithMod.java   
/**
 * 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");
}
项目:pljava    文件IntWithMod.java   
/**
 * 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",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;
}
项目:atsd-jdbc    文件AtsdsqlConverter.java   
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]");
}
项目:atsd-jdbc    文件AtsdsqlConverter.java   
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;
}
项目:atsd-jdbc    文件ExceptionsUtil.java   
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);
    }
}
项目:Camel    文件JdbcProducer.java   
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;
    }
}
项目:soulissapp    文件TagDetailFragment.java   
/**
 * 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);

}
项目:soulissapp    文件TagDetailFragment.java   
@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);
}
项目:soulissapp    文件SoulissDBTagHelper.java   
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;
    }
项目:perspective-backend    文件PlaceholderConfigurer.java   
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;
}
项目:cn1    文件sqlDataExceptionTest.java   
/**
 * @test java.sql.sqlDataException(Throwable)
 */
public void test_Constructor_LThrowable() {
    Throwable cause = new Exception("MYTHROWABLE");
    sqlDataException sqlDataException = new sqlDataException(cause);
    assertNotNull(sqlDataException);
    assertEquals(
            "The reason of sqlDataException should be equals to cause.toString()","java.lang.Exception: MYTHROWABLE",sqlDataException
                    .getMessage());
    assertNull("The sqlState of sqlDataException should be null",sqlDataException.getsqlState());
    assertEquals("The error code of sqlDataException should be 0",sqlDataException.getCause());
}
项目:cn1    文件sqlDataExceptionTest.java   
/**
 * @test java.sql.sqlDataException(String,Throwable)
 */
public void test_Constructor_LStringLThrowable() {
    Throwable cause = new Exception("MYTHROWABLE");
    sqlDataException sqlDataException = new sqlDataException(
            "MYTESTSTRING",cause);
    assertNotNull(sqlDataException);
    assertEquals(
            "The reason of sqlDataException set and get should be equivalent","MYTESTSTRING",sqlDataException.getMessage());
    assertNull("The sqlState of sqlDataException should be null",Throwable)
 */
public void test_Constructor_LStringLStringLThrowable() {
    Throwable cause = new Exception("MYTHROWABLE");
    sqlDataException sqlDataException = new sqlDataException(
            "MYTESTSTRING1","MYTESTSTRING2",cause);
    assertNotNull(sqlDataException);
    assertEquals(
            "The sqlState of sqlDataException set and get should be equivalent",sqlDataException.getsqlState());
    assertEquals(
            "The reason of sqlDataException set and get should be equivalent","MYTESTSTRING1",Throwable)
 */
public void test_Constructor_LStringLStringLThrowable_1() {
    sqlDataException sqlDataException = new sqlDataException(
            "MYTESTSTRING1",null);
    assertNotNull(sqlDataException);
    assertEquals(
            "The sqlState of sqlDataException set and get should be equivalent",0);
    assertNull("The cause of sqlDataException should be null",Throwable)
 */
public void test_Constructor_LStringLStringLThrowable_2() {
    Throwable cause = new Exception("MYTHROWABLE");
    sqlDataException sqlDataException = new sqlDataException(
            "MYTESTSTRING",Throwable)
 */
public void test_Constructor_LStringLStringLThrowable_4() {
    Throwable cause = new Exception("MYTHROWABLE");
    sqlDataException sqlDataException = new sqlDataException(null,Throwable)
 */
public void test_Constructor_LStringLStringLThrowable_6() {
    Throwable cause = new Exception("MYTHROWABLE");
    sqlDataException sqlDataException = new sqlDataException(null,Throwable)
 */
public void test_Constructor_LStringLStringILThrowable() {
    Throwable cause = new Exception("MYTHROWABLE");
    sqlDataException sqlDataException = new sqlDataException(
            "MYTESTSTRING1",1,sqlDataException.getMessage());
    assertEquals("The error code of sqlDataException should be 1",1);
    assertEquals(
            "The cause of sqlDataException set and get should be equivalent",Throwable)
 */
public void test_Constructor_LStringLStringILThrowable_1() {
    sqlDataException sqlDataException = new sqlDataException(
            "MYTESTSTRING1",1);
    assertNull("The cause of sqlDataException should be null",Throwable)
 */
public void test_Constructor_LStringLStringILThrowable_2() {
    Throwable cause = new Exception("MYTHROWABLE");
    sqlDataException sqlDataException = new sqlDataException(
            "MYTESTSTRING1",Throwable)
 */
public void test_Constructor_LStringLStringILThrowable_3() {
    sqlDataException sqlDataException = new sqlDataException(
            "MYTESTSTRING1",Throwable)
 */
public void test_Constructor_LStringLStringILThrowable_4() {
    Throwable cause = new Exception("MYTHROWABLE");
    sqlDataException sqlDataException = new sqlDataException(
            "MYTESTSTRING1",-1,sqlDataException.getMessage());
    assertEquals("The error code of sqlDataException should be -1",-1);
    assertEquals(
            "The cause of sqlDataException set and get should be equivalent",Throwable)
 */
public void test_Constructor_LStringLStringILThrowable_5() {
    sqlDataException sqlDataException = new sqlDataException(
            "MYTESTSTRING1",-1);
    assertNull("The cause of sqlDataException should be null",sqlDataException.getCause());

}
项目:cn1    文件sqlDataExceptionTest.java   
/**
 * @test java.sql.sqlDataException(String,Throwable)
 */
public void test_Constructor_LStringLStringILThrowable_6() {
    Throwable cause = new Exception("MYTHROWABLE");
    sqlDataException sqlDataException = new sqlDataException(
            "MYTESTSTRING",Throwable)
 */
public void test_Constructor_LStringLStringILThrowable_7() {
    sqlDataException sqlDataException = new sqlDataException(
            "MYTESTSTRING",null);
    assertNotNull(sqlDataException);
    assertNotNull(sqlDataException);
    assertNull("The sqlState of sqlDataException should be null",Throwable)
 */
public void test_Constructor_LStringLStringILThrowable_8() {
    Throwable cause = new Exception("MYTHROWABLE");
    sqlDataException sqlDataException = new sqlDataException(
            "MYTESTSTRING",Throwable)
 */
public void test_Constructor_LStringLStringILThrowable_10() {
    Throwable cause = new Exception("MYTHROWABLE");
    sqlDataException sqlDataException = new sqlDataException(
            "MYTESTSTRING",Throwable)
 */
public void test_Constructor_LStringLStringILThrowable_12() {
    Throwable cause = new Exception("MYTHROWABLE");
    sqlDataException sqlDataException = new sqlDataException(null,Throwable)
 */
public void test_Constructor_LStringLStringILThrowable_14() {
    Throwable cause = new Exception("MYTHROWABLE");
    sqlDataException sqlDataException = new sqlDataException(null,Throwable)
 */
public void test_Constructor_LStringLStringILThrowable_15() {
    sqlDataException sqlDataException = new sqlDataException(null,Throwable)
 */
public void test_Constructor_LStringLStringILThrowable_16() {
    Throwable cause = new Exception("MYTHROWABLE");
    sqlDataException sqlDataException = new sqlDataException(null,Throwable)
 */
public void test_Constructor_LStringLStringILThrowable_18() {
    Throwable cause = new Exception("MYTHROWABLE");
    sqlDataException sqlDataException = new sqlDataException(null,sqlDataException.getCause());
}

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。