Hi Andreas,

your old version of castor logs the sql statements only when the
prepared statements gets created and this happens when the database.xml
together with the mapping.xml is loaded. Therefore the logging you
enabled for the Database instance do not help you as you have
recognized. You have to enable logging on the JDO instance before your
configuration gets loaded. To give you an idea how this should look
like, I'll provide you with some lines of code from an old project.

-------------------------------

    private static Logger _log =
            Logger.getLogger(JDOConfiguration.class);

-------------------------------

        _jdo = new JDO();
        _jdo.setLogWriter(getLogWriter("castor", Priority.DEBUG));
        _jdo.setConfiguration(configuration );
        _jdo.setDatabaseName(name);

-------------------------------

    public org.exolab.castor.util.Logger getLogWriter(
            String prefix, Priority priority) {
        JDOLogWriter writer = new JDOLogWriter(_log, priority);

        org.exolab.castor.util.Logger logger = null;
        logger = new org.exolab.castor.util.Logger(writer);
        logger.setPrefix(prefix);

        return logger;
    }

-------------------------------

    private class JDOLogWriter extends StringWriter {

        private Logger      _logger;
        private Priority    _priority;

        public JDOLogWriter(Logger logger, Priority priority) {
            super();

            _logger = logger;
            _priority = priority;
        }

        /**
         * Flush the stream.
         */
        public void flush() {
            super.flush();

            // Pass the buffer on to log4j
            _logger.log(_priority, super.toString());

            // Empty the buffer.
            super.getBuffer().setLength(0);
        }
    }

-------------------------------

Another option to log the SQL statements may be to check if poolman or
mysql offers such an option.

Out of your stacktrace i have no idea what's going wrong. The only thing
i can guess is that there may be something wrong with the mapping of the
class you want to db.create() an instance of.

Regards
Ralf


Andreas Rutvik schrieb:
> Hi Ralf,
> 
> thank you for your suggestion concerning logging. I used an interceptor
> that I set on the JDO instance like this :
> 
> org.apache.log4j.Category cat = Category.getInstance ( this.getClass ( 
> ).getName (  ) );
> Log4jStringWriter            out = new Log4jStringWriter( cat,
> Priority.DEBUG );
> org.exolab.castor.persist.OutputLogInterceptor sqlInterceptor = new
> OutputLogInterceptor( out );
> 
> db.setLogInterceptor ( sqlInterceptor );
> 
> But I'm not so helped by this, in means of being able to see the SQL
> executed. This is the stack trace I get :
> 
> workflow.core.WorkflowStatus
> (<4028fb85079df30301079df30de20004(1406095458),SWIFT(79300001),Thu Nov
> 17 12:19:10 CET 2005(-1645015225)>)
> [17/11/05 12:19:10][WFlowP0             ][DEBUG]
> com.util.GenesysTransaction - CASTOR - Castor: Creating
> workflow.core.WorkflowStatus
> (<4028fb85079df30301079df30de20004(1406095458),SWIFT(79300001),Thu Nov
> 17 12:19:10 CET 2005(-1645015225)>)
> [17/11/05 12:19:10][WFlowP0             ][DEBUG]
> com.util.GenesysTransaction - CASTOR - Castor: Creating
> workflow.core.WorkflowStatus
> (<4028fb85079df30301079df30de20004(1406095458),SWIFT(79300001),Thu Nov
> 17 12:19:10 CET 2005(-1645015225)>)
> [17/11/05 12:19:10][WFlowP0             ][ERROR]
> com.util.GenesysTransaction - cannot create object of type
> workflow.core.WorkflowStatus Nested error: 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 '"status_workflow"
> ("msg_id","domain","tmstamp","uuid","event","status","class_na' 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 '"status_workflow"
> ("msg_id","domain","tmstamp","uuid","event","status","class_na' at line 1"
>     at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:2001)
>     at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1168)
>     at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:1279)
>     at com.mysql.jdbc.Connection.execSQL(Connection.java:2281)
>     at
> com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:1825)
>     at
> com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:1667)
>     at
> com.codestudio.sql.PoolManPreparedStatement.executeUpdate(PoolManPreparedStatement.java:123)
> 
>     at org.exolab.castor.jdo.engine.SQLEngine.create(SQLEngine.java:616)
>     at org.exolab.castor.persist.ClassMolder.create(ClassMolder.java:895)
>     at org.exolab.castor.persist.LockEngine.create(LockEngine.java:458)
>     at
> org.exolab.castor.persist.TransactionContext.create(TransactionContext.java:833)
> 
>     at
> org.exolab.castor.jdo.engine.DatabaseImpl.create(DatabaseImpl.java:345)
> 
> 
> Any ideas of what this can be, since I can't see the SQL executed ?
> 
> Best regards
> /Andreas
> 
> 
>> From: Ralf Joachim <[EMAIL PROTECTED]>
>> Reply-To: [email protected]
>> To: [email protected]
>> Subject: Re: [castor-user] Problem seeing what SQL is executed.
>> Date: Thu, 17 Nov 2005 11:20:40 +0100
>>
>> Hi Andreas,
>>
>> sometimes the version of a software is an interesting information ;-)
>>
>> Seams you are using something like 0.9.5.x. Having said that a lot of
>> things have changed since that time. Only to show some of the new
>> features:
>>
>> - At 0.9.6 we introduced commons-logging which replaced castors internal
>> logging.
>>
>> - At 0.9.9 we added a debugging SQL proxy.
>>
>> If it is an option for you i would suggest you to switch to a newer
>> release of castor e.g. 0.9.9.1 that's been released some days ago.
>>
>> I can not remember exactly how the logging at 0.9.5 worked but you may
>> need to provide a log interceptor that have to be set on the JDO
>> instance. Maybe you can find some hints in the documentation (e.g. FAQ)
>> of this release which can still be downloaded from:
>>
>> http://dist.codehaus.org/castor/
>>
>> Regards
>> Ralf
>>
>>
>> Andreas Rutvik schrieb:
>> > Actually I am using an old version of Castor which was distributed
>> > 17/1-2003. This distribution doesn't have this
>> >
>> > org.exolab.castor.persist.useProxy=true
>> >
>> > Anyway, in the castor.properties file there is a property called
>> >
>> > org.exolab.castor.debug, which I have set to true, but I can't see any
>> > castor logging anyway ?
>> >
>> > Regards
>> > /Andreas
>> >
>> >
>> >> From: Ralf Joachim <[EMAIL PROTECTED]>
>> >> Reply-To: [email protected]
>> >> To: [email protected]
>> >> Subject: Re: [castor-user] Problem seeing what SQL is executed.
>> >> Date: Wed, 16 Nov 2005 18:27:56 +0100
>> >>
>> >> Hi Andreas,
>> >>
>> >> have a look at:
>> >>
>> >> http://castor.codehaus.org/how-to-connection-proxies.html
>> >>
>> >> Regards
>> >> Ralf
>> >>
>> >>
>> >> Andreas Rutvik schrieb:
>> >> > Hi all,
>> >> >
>> >> > since I am a newbie on Castor, as detailed help as possible would be
>> >> > appreciated.
>> >> >
>> >> > I have migrated from Sybase to MySQL, and getting problems when
>> trying
>> >> > to create an Object in the persistent storage.
>> >> >
>> >> > My code looks like this :
>> >> >
>> >> > // use the Castor database connection to persist
>> >> > org.exolab.castor.jdo.Database db = getDBConnection (  );
>> >> > db.create ( obj ); // THIS CALL GIVES ME THE EXCEPTION
>> >> >
>> >> > and I just get the following exception :
>> >> > cannot create object of type workflow.core.WorkflowStatus Nested
>> error:
>> >> > 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 '"status_workflow"
>> >> > ("msg_id","domain","tmstamp","uuid","event","status","class_na' at
>> >> line 1"
>> >> >
>> >> > But this is not much to help since I can't view the whole SQL to be
>> >> > executed. Is there any easy way to view the actual SQL being
>> executed ?
>> >> >
>> >> > Regards
>> >> > /Andreas
>> >> >
>> >> > _________________________________________________________________
>> >> > Hitta rätt på nätet med MSN Search http://search.msn.se/
>> >> >
>> >> >
>> >> > -------------------------------------------------
>> >> > If you wish to unsubscribe from this list, please send an empty
>> message
>> >> > to the following address:
>> >> >
>> >> > [EMAIL PROTECTED]
>> >> > -------------------------------------------------
>> >>
>> >> --
>> >>
>> >> Syscon Ingenieurbüro für
>> >> Meß- und Datentechnik GmbH
>> >> Ralf Joachim
>> >> Raiffeisenstraße 11
>> >> D-72127 Kusterdingen
>> >> Germany
>> >>
>> >> Tel.   +49 7071 3690 52
>> >> Mobil: +49 173 9630135
>> >> Fax    +49 7071 3690 98
>> >>
>> >> Email: [EMAIL PROTECTED]
>> >> Web:   www.syscon-world.de
>> >>
>> >> -------------------------------------------------
>> >> If you wish to unsubscribe from this list, please
>> >> send an empty message to the following address:
>> >>
>> >> [EMAIL PROTECTED]
>> >> -------------------------------------------------
>> >>
>> >
>> > _________________________________________________________________
>> > Chatt: Träffa nya nätkompisar på Habbo Hotel
>> > http://habbohotel.msn.se/habbo/sv/channelizer
>> >
>> >
>> > -------------------------------------------------
>> > If you wish to unsubscribe from this list, please send an empty message
>> > to the following address:
>> >
>> > [EMAIL PROTECTED]
>> > -------------------------------------------------
>>
>> -- 
>>
>> Syscon Ingenieurbüro für
>> Meß- und Datentechnik GmbH
>> Ralf Joachim
>> Raiffeisenstraße 11
>> D-72127 Kusterdingen
>> Germany
>>
>> Tel.   +49 7071 3690 52
>> Mobil: +49 173 9630135
>> Fax    +49 7071 3690 98
>>
>> Email: [EMAIL PROTECTED]
>> Web:   www.syscon-world.de
>>
>> -------------------------------------------------
>> If you wish to unsubscribe from this list, please
>> send an empty message to the following address:
>>
>> [EMAIL PROTECTED]
>> -------------------------------------------------
>>
> 
> _________________________________________________________________
> Lättare att hitta drömresan med MSN Resor http://www.msn.se/resor/
> 
> 
> -------------------------------------------------
> If you wish to unsubscribe from this list, please send an empty message
> to the following address:
> 
> [EMAIL PROTECTED]
> -------------------------------------------------

-- 

Syscon Ingenieurbüro für
Meß- und Datentechnik GmbH
Ralf Joachim
Raiffeisenstraße 11
D-72127 Kusterdingen
Germany

Tel.   +49 7071 3690 52
Mobil: +49 173 9630135
Fax    +49 7071 3690 98

Email: [EMAIL PROTECTED]
Web:   www.syscon-world.de

-------------------------------------------------
If you wish to unsubscribe from this list, please 
send an empty message to the following address:

[EMAIL PROTECTED]
-------------------------------------------------

Reply via email to