You are viewing a plain text version of this content. The canonical link for it is here.
Posted to ojb-user@db.apache.org by Ajitesh Das <ad...@zona.net> on 2004/09/09 04:07:32 UTC

MSSQL And OJB/Torque issue with image datatype..Will Velocity solve my problem?

Hi:

I want to store an *supersize* byte array into a db table. 

Below I have described the issues that I have. My question: 

How do I control SQL for Schema? Do I have to write my own Velocity
template and add that path to db.profile. 

 

 

 

I have made the followings changes:

 

 

DB Type : MSSQL

 

In db-schema.xml:

 

<?xml version="1.0" encoding="ISO-8859-1"?>

<!DOCTYPE database SYSTEM
"http://jakarta.apache.org/turbine/dtd/database.dtd">

<database name="@DATABASE_DEFAULT@" defaultIdMethod="none" baseClass=""
>

  <table name="PROPERTY" >

        <column name="ID" required="true" primaryKey="true"
type="INTEGER" >

        </column>

        <column name=" PROPERTY_NAME" required="true" primaryKey="false"
type="VARBINARY" >

        </column>

        <column name="PROPERTY_VALUE" required="true" primaryKey="false"
type="VARBINARY" >

        </column>

 </table>

</database>

 

It creates IMAGE datatype in MSSQL Server.

 

In repository.xml:

<class-descriptor 

            class="com.xxx.Property"

            table="PROPERTY"

        >

        

        <attribute 

                attribute-name="DB_NAME"

                attribute-value="mydb"

            >

        </attribute>

        

        <field-descriptor id="1"

            name="dbId"

            column="ID"

            jdbc-type="INTEGER"

            primarykey="true"

            nullable="false"

            indexed="true"

            autoincrement="true"

            locking="false"

            default-fetch="false"

        />

        <field-descriptor id="2"

            name="propertyName"

            column="PROPERTY_NAME"

            jdbc-type="VARBINARY"

            primarykey="false"

            nullable="true"

            indexed="false"

            autoincrement="false"

            locking="false"

            default-fetch="false"

            conversion="com.xxx.yyy.Converter"

        />

        <field-descriptor id="3"

            name="propertyValue"

            column="PROPERTY_VALUE"

            jdbc-type="VARBINARY"

            primarykey="false"

            nullable="true"

            indexed="false"

            autoincrement="false"

            locking="false"

            default-fetch="false"

            conversion="com.xxx.yyy.Converter"

        />

    </class-descriptor>

 

When I run simple queryI get the following exception: but running in
MySQL is fine. 

 

 

[org.apache.ojb.broker.accesslayer.JdbcAccessImpl] ERROR: SQLException
during the execution of the query (for a com.xxx.Property): The text,
ntext, and image data types cannot be compared or sorted, except when
using IS NULL or LIKE operator.

The text, ntext, and image data types cannot be compared or sorted,
except when using IS NULL or LIKE operator.

java.sql.SQLException: The text, ntext, and image data types cannot be
compared or sorted, except when using IS NULL or LIKE operator.

      

       at
net.sourceforge.jtds.jdbc.SQLDiagnostic.addDiagnostic(SQLDiagnostic.j

ava:366)

      at
net.sourceforge.jtds.jdbc.TdsCore.tdsErrorToken(TdsCore.java:1992)

        at
net.sourceforge.jtds.jdbc.TdsCore.nextToken(TdsCore.java:1594)

        at
net.sourceforge.jtds.jdbc.TdsCore.getMoreResults(TdsCore.java:490)

        at
net.sourceforge.jtds.jdbc.JtdsStatement.executeSQLQuery(JtdsStatement

.java:262)

        at
net.sourceforge.jtds.jdbc.JtdsPreparedStatement.executeQuery(JtdsPrep

aredStatement.java:614)

        at
org.apache.ojb.broker.accesslayer.JdbcAccessImpl.executeQuery(Unknown

 Source)

        at org.apache.ojb.broker.accesslayer.RsIterator.<init>(Unknown
Source)

        at
org.apache.ojb.broker.core.RsIteratorFactoryImpl.createRsIterator(Unk

nown Source)

        at
org.apache.ojb.broker.core.PersistenceBrokerImpl.getRsIteratorFromQue

ry(Unknown Source)

        at
org.apache.ojb.broker.core.PersistenceBrokerImpl.getIteratorFromQuery

(Unknown Source)

        at
org.apache.ojb.broker.core.PersistenceBrokerImpl.getIteratorByQuery(U

nknown Source)

        at
org.apache.ojb.broker.core.DelegatingPersistenceBroker.getIteratorByQ

uery(Unknown Source)


Re: MSSQL And OJB/Torque issue with image datatype..Will Velocity solve my problem?

Posted by Brian McCallister <mc...@forthillcompany.com>.
This is a limitation of (MS) SQL:

> [org.apache.ojb.broker.accesslayer.JdbcAccessImpl] ERROR: SQLException
> during the execution of the query (for a com.xxx.Property): The text,
> ntext, and image data types cannot be compared or sorted, except when
> using IS NULL or LIKE operator.

What does the actual SQL look like, and what does the query you are 
running look like?

-Brian

On Sep 8, 2004, at 10:07 PM, Ajitesh Das wrote:

> Hi:
>
> I want to store an *supersize* byte array into a db table.
>
> Below I have described the issues that I have. My question:
>
> How do I control SQL for Schema? Do I have to write my own Velocity
> template and add that path to db.profile.
>
>
>
>
>
>
>
> I have made the followings changes:
>
>
>
>
>
> DB Type : MSSQL
>
>
>
> In db-schema.xml:
>
>
>
> <?xml version="1.0" encoding="ISO-8859-1"?>
>
> <!DOCTYPE database SYSTEM
> "http://jakarta.apache.org/turbine/dtd/database.dtd">
>
> <database name="@DATABASE_DEFAULT@" defaultIdMethod="none" baseClass=""
>>
>
>   <table name="PROPERTY" >
>
>         <column name="ID" required="true" primaryKey="true"
> type="INTEGER" >
>
>         </column>
>
>         <column name=" PROPERTY_NAME" required="true" 
> primaryKey="false"
> type="VARBINARY" >
>
>         </column>
>
>         <column name="PROPERTY_VALUE" required="true" 
> primaryKey="false"
> type="VARBINARY" >
>
>         </column>
>
>  </table>
>
> </database>
>
>
>
> It creates IMAGE datatype in MSSQL Server.
>
>
>
> In repository.xml:
>
> <class-descriptor
>
>             class="com.xxx.Property"
>
>             table="PROPERTY"
>
>>
>
>
>
>         <attribute
>
>                 attribute-name="DB_NAME"
>
>                 attribute-value="mydb"
>
>>
>
>         </attribute>
>
>
>
>         <field-descriptor id="1"
>
>             name="dbId"
>
>             column="ID"
>
>             jdbc-type="INTEGER"
>
>             primarykey="true"
>
>             nullable="false"
>
>             indexed="true"
>
>             autoincrement="true"
>
>             locking="false"
>
>             default-fetch="false"
>
>         />
>
>         <field-descriptor id="2"
>
>             name="propertyName"
>
>             column="PROPERTY_NAME"
>
>             jdbc-type="VARBINARY"
>
>             primarykey="false"
>
>             nullable="true"
>
>             indexed="false"
>
>             autoincrement="false"
>
>             locking="false"
>
>             default-fetch="false"
>
>             conversion="com.xxx.yyy.Converter"
>
>         />
>
>         <field-descriptor id="3"
>
>             name="propertyValue"
>
>             column="PROPERTY_VALUE"
>
>             jdbc-type="VARBINARY"
>
>             primarykey="false"
>
>             nullable="true"
>
>             indexed="false"
>
>             autoincrement="false"
>
>             locking="false"
>
>             default-fetch="false"
>
>             conversion="com.xxx.yyy.Converter"
>
>         />
>
>     </class-descriptor>
>
>
>
> When I run simple queryI get the following exception: but running in
> MySQL is fine.
>
>
>
>
>
> [org.apache.ojb.broker.accesslayer.JdbcAccessImpl] ERROR: SQLException
> during the execution of the query (for a com.xxx.Property): The text,
> ntext, and image data types cannot be compared or sorted, except when
> using IS NULL or LIKE operator.
>
> The text, ntext, and image data types cannot be compared or sorted,
> except when using IS NULL or LIKE operator.
>
> java.sql.SQLException: The text, ntext, and image data types cannot be
> compared or sorted, except when using IS NULL or LIKE operator.
>
>
>
>        at
> net.sourceforge.jtds.jdbc.SQLDiagnostic.addDiagnostic(SQLDiagnostic.j
>
> ava:366)
>
>       at
> net.sourceforge.jtds.jdbc.TdsCore.tdsErrorToken(TdsCore.java:1992)
>
>         at
> net.sourceforge.jtds.jdbc.TdsCore.nextToken(TdsCore.java:1594)
>
>         at
> net.sourceforge.jtds.jdbc.TdsCore.getMoreResults(TdsCore.java:490)
>
>         at
> net.sourceforge.jtds.jdbc.JtdsStatement.executeSQLQuery(JtdsStatement
>
> .java:262)
>
>         at
> net.sourceforge.jtds.jdbc.JtdsPreparedStatement.executeQuery(JtdsPrep
>
> aredStatement.java:614)
>
>         at
> org.apache.ojb.broker.accesslayer.JdbcAccessImpl.executeQuery(Unknown
>
>  Source)
>
>         at org.apache.ojb.broker.accesslayer.RsIterator.<init>(Unknown
> Source)
>
>         at
> org.apache.ojb.broker.core.RsIteratorFactoryImpl.createRsIterator(Unk
>
> nown Source)
>
>         at
> org.apache.ojb.broker.core.PersistenceBrokerImpl.getRsIteratorFromQue
>
> ry(Unknown Source)
>
>         at
> org.apache.ojb.broker.core.PersistenceBrokerImpl.getIteratorFromQuery
>
> (Unknown Source)
>
>         at
> org.apache.ojb.broker.core.PersistenceBrokerImpl.getIteratorByQuery(U
>
> nknown Source)
>
>         at
> org.apache.ojb.broker.core.DelegatingPersistenceBroker.getIteratorByQ
>
> uery(Unknown Source)
>



---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-user-help@db.apache.org