You are viewing a plain text version of this content. The canonical link for it is here.
Posted to ojb-dev@db.apache.org by Mike Ahlers <mi...@hippo.nl> on 2004/04/09 12:56:49 UTC

Problem with SequenceManagerNativeImpl and MySql

Hi,

I am using rc6 and MySQL (4.0.18-nt) database. All I want is to have the 
primary key after a store (for new object), the database uses 
auto-increment, and I am experimenting with several SequenceManagers.

The SequenceManagerInMemoryImpl works, however not suitable for multiple 
instances will work on the database. The documentation says I should use 
a special Manager because of MySQL and therefore I am using 
SequenceManagerNativeImpl. This works partially, as in, it generates 
negative primary keys (and not unique), but when I am setting 
access="readonly" in my reposity for field-descriptor I receive the 
following error:

[org.apache.ojb.broker.core.PersistenceBrokerImpl] ERROR: SQLException 
during SequenceManager.afterStore (for a nl.hippo.nvpt.Articles): Syntax 
error or access
violation,  message from server: "You have an error in your SQL syntax.  
Check the manual that corresponds to your MySQL server version for the 
right syntax to use near 'CALL IDENTITY()' at line 1"
Syntax error or access violation,  message from server: "You have an 
error in your SQL syntax.  Check the manual that corresponds to your 
MySQL server version for the right syntax to use near 'CALL IDENTITY()' 
at line 1" java.sql.SQLException: Syntax error or access violation,  
message from server: "
You have an error in your SQL syntax.  Check the manual that corresponds 
to your MySQL server version for the right syntax to use near 'CALL 
IDENTITY()' at line 1"
        at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:1876)
        at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1098)
        at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:1192)
        at com.mysql.jdbc.MysqlIO.sqlQuery(MysqlIO.java:1153)
        at com.mysql.jdbc.Connection.execSQL(Connection.java:2048)
        at com.mysql.jdbc.Connection.execSQL(Connection.java:2005)
        at com.mysql.jdbc.Statement.executeQuery(Statement.java:1156)
        at 
org.apache.ojb.broker.util.sequence.SequenceManagerNativeImpl.getLastInsert(SequenceManagerNativeImpl.java:263)
        at 
org.apache.ojb.broker.util.sequence.SequenceManagerNativeImpl.afterStore(SequenceManagerNativeImpl.java:155)
        at 
org.apache.ojb.broker.core.PersistenceBrokerImpl.storeToDb(PersistenceBrokerImpl.java:1465)
        at 
org.apache.ojb.broker.core.PersistenceBrokerImpl.store(PersistenceBrokerImpl.java:1378)
        at 
org.apache.ojb.broker.core.PersistenceBrokerImpl.store(PersistenceBrokerImpl.java:730)
        at 
org.apache.ojb.broker.core.DelegatingPersistenceBroker.store(DelegatingPersistenceBroker.java:165)
        at 
org.apache.ojb.broker.core.DelegatingPersistenceBroker.store(DelegatingPersistenceBroker.java:165)

Current setup:
--- start snippet ---
<sequence-manager 
className="org.apache.ojb.broker.util.sequence.SequenceManagerNativeImpl">
            <attribute attribute-name="grabSize" attribute-value="10"/>
</sequence-manager>

<class-descriptor class="nl.hippo.nvpt.Articles" table="ARTICLES">
        <field-descriptor name="id" primarykey="true" 
autoincrement="true" access="readonly" nullable="false" 
default-fetch="true" column="ID" jdbc-type="INTEGER"/>
        ....
--- end snippet ---

What am I missing here? Or are there other solutions?

Thanks in advance,
Mike Ahlers

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


Re: Problem with SequenceManagerNativeImpl and MySql

Posted by Mike Ahlers <mi...@hippo.nl>.
Hi Armin,

Thanks! That indeed solved the problem! Reply-posted this on user-list 
for community :)
And no, the hippo is just fine!

- Mike

Armin Waibel wrote:

> Hi Mike,
>
> I think you don't have specified the correct database in your 
> jdbc-connection-descriptor:
>
> <jdbc-connection-descriptor
>            jcd-alias="default"
>            default-connection="true"
> ==>!!        platform="Hsqldb"
>            jdbc-level="2.0"
> .......
>
> The platform attribute should be platform="MySQL" in your case. This 
> enable OJB to use the "right" platform class.
> see http://db.apache.org/ojb/platforms.html
> and http://db.apache.org/ojb/repository.html#jdbc-connection-descriptor
> for more info.
>
> > during SequenceManager.afterStore (for a nl.hippo.nvpt.Articles):
> > Syntax
> > error or access
>
> or maybe OJB can't store the hippo ;-)
>
> By the way, please use the user-list for these kinds of problems to 
> make it possible for other user to benefit/learn.
>
> regards,
> Armin
>
> Mike Ahlers wrote:
>
>> Hi,
>>
>> I am using rc6 and MySQL (4.0.18-nt) database. All I want is to have 
>> the primary key after a store (for new object), the database uses 
>> auto-increment, and I am experimenting with several SequenceManagers.
>>
>> The SequenceManagerInMemoryImpl works, however not suitable for 
>> multiple instances will work on the database. The documentation says 
>> I should use a special Manager because of MySQL and therefore I am 
>> using SequenceManagerNativeImpl. This works partially, as in, it 
>> generates negative primary keys (and not unique), but when I am 
>> setting access="readonly" in my reposity for field-descriptor I 
>> receive the following error:
>>
>> [org.apache.ojb.broker.core.PersistenceBrokerImpl] ERROR: 
>> SQLException during SequenceManager.afterStore (for a 
>> nl.hippo.nvpt.Articles): Syntax error or access
>> violation,  message from server: "You have an error in your SQL 
>> syntax.  Check the manual that corresponds to your MySQL server 
>> version for the right syntax to use near 'CALL IDENTITY()' at line 1"
>> Syntax error or access violation,  message from server: "You have an 
>> error in your SQL syntax.  Check the manual that corresponds to your 
>> MySQL server version for the right syntax to use near 'CALL 
>> IDENTITY()' at line 1" java.sql.SQLException: Syntax error or access 
>> violation,  message from server: "
>> You have an error in your SQL syntax.  Check the manual that 
>> corresponds to your MySQL server version for the right syntax to use 
>> near 'CALL IDENTITY()' at line 1"
>>        at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:1876)
>>        at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1098)
>>        at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:1192)
>>        at com.mysql.jdbc.MysqlIO.sqlQuery(MysqlIO.java:1153)
>>        at com.mysql.jdbc.Connection.execSQL(Connection.java:2048)
>>        at com.mysql.jdbc.Connection.execSQL(Connection.java:2005)
>>        at com.mysql.jdbc.Statement.executeQuery(Statement.java:1156)
>>        at 
>> org.apache.ojb.broker.util.sequence.SequenceManagerNativeImpl.getLastInsert(SequenceManagerNativeImpl.java:263) 
>>
>>        at 
>> org.apache.ojb.broker.util.sequence.SequenceManagerNativeImpl.afterStore(SequenceManagerNativeImpl.java:155) 
>>
>>        at 
>> org.apache.ojb.broker.core.PersistenceBrokerImpl.storeToDb(PersistenceBrokerImpl.java:1465) 
>>
>>        at 
>> org.apache.ojb.broker.core.PersistenceBrokerImpl.store(PersistenceBrokerImpl.java:1378) 
>>
>>        at 
>> org.apache.ojb.broker.core.PersistenceBrokerImpl.store(PersistenceBrokerImpl.java:730) 
>>
>>        at 
>> org.apache.ojb.broker.core.DelegatingPersistenceBroker.store(DelegatingPersistenceBroker.java:165) 
>>
>>        at 
>> org.apache.ojb.broker.core.DelegatingPersistenceBroker.store(DelegatingPersistenceBroker.java:165) 
>>
>>
>> Current setup:
>> --- start snippet ---
>> <sequence-manager 
>> className="org.apache.ojb.broker.util.sequence.SequenceManagerNativeImpl"> 
>>
>>            <attribute attribute-name="grabSize" attribute-value="10"/>
>> </sequence-manager>
>>
>> <class-descriptor class="nl.hippo.nvpt.Articles" table="ARTICLES">
>>        <field-descriptor name="id" primarykey="true" 
>> autoincrement="true" access="readonly" nullable="false" 
>> default-fetch="true" column="ID" jdbc-type="INTEGER"/>
>>        ....
>> --- end snippet ---
>>
>> What am I missing here? Or are there other solutions?
>>
>> Thanks in advance,
>> Mike Ahlers
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: ojb-dev-unsubscribe@db.apache.org
>> For additional commands, e-mail: ojb-dev-help@db.apache.org
>>
>>
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: ojb-dev-unsubscribe@db.apache.org
> For additional commands, e-mail: ojb-dev-help@db.apache.org
>
>


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


Re: Problem with SequenceManagerNativeImpl and MySql

Posted by Armin Waibel <ar...@apache.org>.
Hi Mike,

I think you don't have specified the correct database in your 
jdbc-connection-descriptor:

<jdbc-connection-descriptor
    		jcd-alias="default"
    		default-connection="true"
==>!!    	platform="Hsqldb"
    		jdbc-level="2.0"
.......

The platform attribute should be platform="MySQL" in your case. This 
enable OJB to use the "right" platform class.
see http://db.apache.org/ojb/platforms.html
and http://db.apache.org/ojb/repository.html#jdbc-connection-descriptor
for more info.

 > during SequenceManager.afterStore (for a nl.hippo.nvpt.Articles):
 > Syntax
 > error or access

or maybe OJB can't store the hippo ;-)

By the way, please use the user-list for these kinds of problems to make 
it possible for other user to benefit/learn.

regards,
Armin

Mike Ahlers wrote:
> Hi,
> 
> I am using rc6 and MySQL (4.0.18-nt) database. All I want is to have the 
> primary key after a store (for new object), the database uses 
> auto-increment, and I am experimenting with several SequenceManagers.
> 
> The SequenceManagerInMemoryImpl works, however not suitable for multiple 
> instances will work on the database. The documentation says I should use 
> a special Manager because of MySQL and therefore I am using 
> SequenceManagerNativeImpl. This works partially, as in, it generates 
> negative primary keys (and not unique), but when I am setting 
> access="readonly" in my reposity for field-descriptor I receive the 
> following error:
> 
> [org.apache.ojb.broker.core.PersistenceBrokerImpl] ERROR: SQLException 
> during SequenceManager.afterStore (for a nl.hippo.nvpt.Articles): Syntax 
> error or access
> violation,  message from server: "You have an error in your SQL syntax.  
> Check the manual that corresponds to your MySQL server version for the 
> right syntax to use near 'CALL IDENTITY()' at line 1"
> Syntax error or access violation,  message from server: "You have an 
> error in your SQL syntax.  Check the manual that corresponds to your 
> MySQL server version for the right syntax to use near 'CALL IDENTITY()' 
> at line 1" java.sql.SQLException: Syntax error or access violation,  
> message from server: "
> You have an error in your SQL syntax.  Check the manual that corresponds 
> to your MySQL server version for the right syntax to use near 'CALL 
> IDENTITY()' at line 1"
>        at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:1876)
>        at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1098)
>        at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:1192)
>        at com.mysql.jdbc.MysqlIO.sqlQuery(MysqlIO.java:1153)
>        at com.mysql.jdbc.Connection.execSQL(Connection.java:2048)
>        at com.mysql.jdbc.Connection.execSQL(Connection.java:2005)
>        at com.mysql.jdbc.Statement.executeQuery(Statement.java:1156)
>        at 
> org.apache.ojb.broker.util.sequence.SequenceManagerNativeImpl.getLastInsert(SequenceManagerNativeImpl.java:263) 
> 
>        at 
> org.apache.ojb.broker.util.sequence.SequenceManagerNativeImpl.afterStore(SequenceManagerNativeImpl.java:155) 
> 
>        at 
> org.apache.ojb.broker.core.PersistenceBrokerImpl.storeToDb(PersistenceBrokerImpl.java:1465) 
> 
>        at 
> org.apache.ojb.broker.core.PersistenceBrokerImpl.store(PersistenceBrokerImpl.java:1378) 
> 
>        at 
> org.apache.ojb.broker.core.PersistenceBrokerImpl.store(PersistenceBrokerImpl.java:730) 
> 
>        at 
> org.apache.ojb.broker.core.DelegatingPersistenceBroker.store(DelegatingPersistenceBroker.java:165) 
> 
>        at 
> org.apache.ojb.broker.core.DelegatingPersistenceBroker.store(DelegatingPersistenceBroker.java:165) 
> 
> 
> Current setup:
> --- start snippet ---
> <sequence-manager 
> className="org.apache.ojb.broker.util.sequence.SequenceManagerNativeImpl">
>            <attribute attribute-name="grabSize" attribute-value="10"/>
> </sequence-manager>
> 
> <class-descriptor class="nl.hippo.nvpt.Articles" table="ARTICLES">
>        <field-descriptor name="id" primarykey="true" 
> autoincrement="true" access="readonly" nullable="false" 
> default-fetch="true" column="ID" jdbc-type="INTEGER"/>
>        ....
> --- end snippet ---
> 
> What am I missing here? Or are there other solutions?
> 
> Thanks in advance,
> Mike Ahlers
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: ojb-dev-unsubscribe@db.apache.org
> For additional commands, e-mail: ojb-dev-help@db.apache.org
> 
> 
> 

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