cayenne-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Andrus Adamchik <and...@objectstyle.org>
Subject Re: java.sql.SQLException: Unknown Types value
Date Fri, 21 Jun 2013 15:08:00 GMT
The attachments are stripped by the mailing list software. But it doesn't matter… Integer.MAX_VALUE
is used by org.apache.cayenne.dba.TypesMapping to indicate it can't map a Java type to a JDBC
type:

public static final int NOT_DEFINED = Integer.MAX_VALUE;

So this happens upstream somewhere from the problematic code. Could you maybe locate all references
to NOT_DEFINED inside TypesMapping and put breakpoints there. Then you can see which one is
hit in debugger, analyze what's causing it, and post the stack trace of it here. 

Thanks,
Andrus

On Jun 21, 2013, at 2:16 AM, Mick Fong <Mick.Fong@kti.wa.edu.au> wrote:
> Hi Andrus,
> 
> Yes I am running, 3.0.2 (on windows).
> 
> The type value I get is "2147483647" (which is the max int obviously)
> 
> Attached image shows it in the debugger.
> 
> 
> cheers
> 
> Mick Fong
> Simulator Engineer
> 
> p (08) 9193 8921
> m 0413 113 099
> f (08) 9192 9111
> e mick.fong@kti.wa.edu.au
> a PO Box 1380, Broome WA 6725
> 
> -----Original Message-----
> From: Andrus Adamchik [mailto:andrus@objectstyle.org] 
> Sent: Friday, 21 June 2013 4:05 AM
> To: user@cayenne.apache.org
> Subject: Re: java.sql.SQLException: Unknown Types value
> 
> From checking the sources, I am also assuming 3.0.*:
> 
>   public void setJdbcObject(
>           PreparedStatement st,
>           Object value,
>           int pos,
>           int type,
>           int scale) throws Exception {
> 
>       // if this is a CLOB column, set the value as "String"
>       // instead. This should work with most drivers
>       if (type == Types.CLOB) {
>           st.setString(pos, (String) value);
>       }
>       else if (scale != -1) {
>           st.setObject(pos, value, type, scale);
>       }
>       else {
>          // THIS IS LINE 169
>           st.setObject(pos, value, type);
>       }
>   }
> 
> Mick, Could you possibly run this in debugger and tell us what the value of the "type"
variable is?
> 
> Andrus
> 
> 
> On Jun 20, 2013, at 9:13 AM, Michael Gentry <mgentry@masslight.net> wrote:
> 
>> Hi Mick,
>> 
>> Did you maybe map a CHAR in your Cayenne DbEntity to a VARCHAR column 
>> or vice-versa?  I could see this causing a problem.
>> 
>> We use views just fine with Cayenne and have both CHAR and VARCHAR 
>> mappings (to the appropriate DB types) in Cayenne 3.0.  You didn't 
>> mention which version of Cayenne you are using, so I'm guessing 3.0 currently.
>> 
>> mrg
>> 
>> 
>> 
>> On Wed, Jun 19, 2013 at 9:11 PM, Mick Fong <Mick.Fong@kti.wa.edu.au> wrote:
>> 
>>> Hi Michael,
>>> 
>>> The type is definitely a varchar in the view.
>>> 
>>> The error is when the you are setting the query object for the 
>>> PreparedStatement. It appears that the 
>>> org.apache.cayenne.access.types.CharType is not being recognised as a 
>>> MySQL varchar type.
>>> 
>>> The exception is thrown from a switch on the parameter SQL type:
>>> 
>>> switch (targetSqlType) {
>>> .
>>> .
>>> case Types.CHAR:
>>> case Types.VARCHAR:
>>> case Types.LONGVARCHAR:
>>>  if (parameterObj instanceof BigDecimal) {
>>> 
>>> setString(parameterIndex,(StringUtils.fixDecimalExponent(StringUtils.
>>> consistentToString((BigDecimal)
>>> parameterObj))));
>>>  } else {
>>>    setString(parameterIndex, parameterObj.toString());
>>>  }
>>> 
>>> break;
>>> .
>>> .
>>> default:
>>>  throw
>>> SQLError.createSQLException(Messages.getString("PreparedStatement.16"
>>> ),
>>> //$NON-NLS-1$
>>>    SQLError.SQL_STATE_GENERAL_ERROR, getExceptionInterceptor()); }
>>> 
>>> 
>>> The property value for the message is:
>>> PreparedStatement.16=Unknown Types value
>>> 
>>> 
>>> The error occurs just when setting the parameters because the 
>>> CharType is not recognised.
>>> 
>>> thanks
>>> 
>>> mick
>>> 
>>> [Kimberley Training Institute Logo]
>>> Toll Free: 1300 996 573 | Website: www.kti.wa.edu.au< 
>>> http://www.kti.wa.edu.au> Find us on 
>>> Facebook<http://www.facebook.com/kimberleytraininginstitute>
>>> 
>>> Please consider the environment before printing this email.
>>> 
> 


Mime
View raw message