Naxe,
First, sorry. I think you e-mailed me about this and I dropped it.
Looking around, it looks like SQL Server sometimes sets these warnings on Connections it issues. If so, and if Hibernate reports warnings set on Connections, then you'll see them until somebody calls clearWarnings() on your Connections.
c3p0 should really be managing the SQLWarnings, as part of Connection state. It looks like it doesn't, though. It will before its next minor release! :) Sorry!
For now, the easiest way to resolve this would be to get SQLServer to stop setting these warnings on Connections. If you can't do that, you can write a c3p0 ConnectionCustomizer, like so...
Code:
package com.zaxe.foo;
import com.mchange.v2.c3p0.*;
import java.sql.*;
public class ClearWarningsConnectionCustomizer
extends AbstractConnectionCustomizer
{
public void onAcquire( Connection c, String pdsIdt )
{
SQLWarning warning = c.getWarnings();
while (warning != null)
{
logWarning(warning);
warning = warning.getNextWarning();
}
c.clearWarnings();
}
private void logWarning(SQLWarning w)
{ /* log at DEBUG level */ }
}
This will only work in c3p0-0.9.1-preX [use c3p0-0.9.1-pre11]. Once you've defined the class, use the c3p0 config param c3p0.connectionCustomizerClassName to get c3p0 to instantiate the class and attach it to your DataSource. [See the docs to c3p0-0.9.1-pre11.]
If you don't know where to log the warnings, here's the same example modified to use c3p0's built-in logging library:
Code:
package com.zaxe.foo;
import com.mchange.v2.c3p0.*;
import com.mchange.v2.log.*;
import java.sql.*;
public class ClearWarningsConnectionCustomizer
extends AbstractConnectionCustomizer
{
private final static MLogger logger = MLog.getLogger( ClearWarningsConnectionCustomizer.class );
public void onAcquire( Connection c, String pdsIdt )
{
SQLWarning warning = c.getWarnings();
while (warning != null)
{
logWarning(warning);
warning = warning.getNextWarning();
}
c.clearWarnings();
}
private void logWarning(SQLWarning w)
{ logger.log(MLevel.FINE, "Warning set on Connection: " + w, w); }
}
Hope this helps! Good luck!
Steve