0

This my method and every time I run it always say "could not read column value from result set: cColor; String index out of range: 0" and throws Exception in thread "main" java.lang.StringIndexOutOfBoundsException: String index out of range: 0. Any Idea ? Can anybody tell me where's the error ?

    --OpenSession here--
    Query query = session.createSQLQuery("SELECT * FROM db.tblUnits "
            + "WHERE csTat = :paramStation AND cbrach = :paramLocId" 
            + "AND (cType = 'repo units' OR cType = 'svc units')")
            .setParameter("paramLocId", locId)
            .setParameter("paramStation", station);

    List<Object[]> oAvailableUnits = (List<Object[]>) query.list();

    --CloseSession here--
5
  • why multithreading tag? Commented Aug 12, 2017 at 4:04
  • 2
    Your stack trace contains line numbers and file names that tell you where the error is. It's no good asking us here - especially if you don't share the stack trace. In any case, it's almost certainly not in the code that you've actually shown us here. Commented Aug 12, 2017 at 4:07
  • 3
    Typo. You are missing a white space between ":paramLocId" and "AND" on the continuing String concatenation on the next line. Commented Aug 12, 2017 at 4:14
  • @Johny sorry, it's a mistake. Commented Aug 12, 2017 at 4:46
  • I've got it, I just changed the cColor datatype char into varchar in the database then it works. But still, I don't why java cannot read the length of the datatype char. Anyway, thanks for your responds. Commented Aug 12, 2017 at 5:09

1 Answer 1

1

It happens that the cColor column is empty and its datatype is char, so I just changed the datatype into varchar because java cannot read the char datatype.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.