[
http://jira.codehaus.org/browse/MSQL-45?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Steve Etherington updated MSQL-45:
----------------------------------
Attachment: sql-maven-less-noisy.patch
Hi Robert,
I have attached a less noisy patch. The change is to the execSql method, which
now looks like this:
private void execSQL( String sql, PrintStream out )
throws SQLException
{
// Check and ignore empty statements
if ( "".equals( sql.trim() ) )
{
return;
}
ResultSet resultSet = null;
try
{
totalStatements++;
getLog().debug( "SQL: " + sql );
boolean ret;
int updateCount = 0, updateCountTotal = 0;
ret = statement.execute( sql );
do
{
if ( !ret )
{
updateCount = statement.getUpdateCount();
if ( updateCount != -1 )
{
updateCountTotal += updateCount;
}
}
else
{
resultSet = statement.getResultSet();
if ( printResultSet )
{
printResultSet( resultSet, out );
}
}
ret = statement.getMoreResults();
} while ( ret );
getLog().debug( updateCountTotal + " rows affected" );
if ( printResultSet )
{
StringBuffer line = new StringBuffer();
line.append( updateCountTotal ).append( " rows affected" );
out.println( line );
}
SQLWarning warning = conn.getWarnings();
while ( warning != null )
{
getLog().debug( warning + " sql warning" );
warning = warning.getNextWarning();
}
conn.clearWarnings();
successfulStatements++;
}
catch ( SQLException e )
{
getLog().error( "Failed to execute: " + sql );
if ( !ON_ERROR_CONTINUE.equalsIgnoreCase( getOnError() ) )
{
throw e;
}
getLog().error( e.toString() );
}
finally
{
if ( resultSet != null )
{
resultSet.close();
}
}
}
FYI, we have been the previous patched version in our continuous integration
and dev builds for the last couple of months. There have been no problems with
the patch.
thanks
Steve
> sql task: execute script on lucid errors with NullPointerException
> ------------------------------------------------------------------
>
> Key: MSQL-45
> URL: http://jira.codehaus.org/browse/MSQL-45
> Project: Maven 2.x SQL Plugin
> Issue Type: Bug
> Affects Versions: 1.3
> Environment: ubuntu, java 1.6,
> Reporter: Steve Etherington
> Attachments: maven-sql.patch, sql-maven-less-noisy.patch
>
>
> The plugin throws an exception when executing an update script against Lucid.
> (Fails for create table, drop table, and insert, at least.)
> [INFO] Executing file: [...] create_table.sql
> [ERROR] Failed to execute: CREATE TABLE [... my table]
> [ERROR] java.sql.SQLException: java.lang.NullPointerException
> at
> de.simplicit.vjdbc.VirtualStatement.getResultSet(VirtualStatement.java:152)
> at org.codehaus.mojo.sql.SqlExecMojo.execSQL(SqlExecMojo.java:817)
> at
> org.codehaus.mojo.sql.SqlExecMojo.runStatements(SqlExecMojo.java:782)
> at org.codehaus.mojo.sql.SqlExecMojo.access$200(SqlExecMojo.java:53)
> at
> org.codehaus.mojo.sql.SqlExecMojo$Transaction.runTransaction(SqlExecMojo.java:992)
> at
> org.codehaus.mojo.sql.SqlExecMojo$Transaction.access$100(SqlExecMojo.java:939)
> at org.codehaus.mojo.sql.SqlExecMojo.execute(SqlExecMojo.java:463)
> at
> org.apache.maven.plugin.DefaultPluginManager.executeMojo(DefaultPluginManager.java:490)
> at
> org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoals(DefaultLifecycleExecutor.java:694)
> at
> org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalWithLifecycle(DefaultLifecycleExecutor.java:556)
> at
> org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoal(DefaultLifecycleExecutor.java:535)
> at
> org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalAndHandleFailures(DefaultLifecycleExecutor.java:387)
> at
> org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeTaskSegments(DefaultLifecycleExecutor.java:348)
> at
> org.apache.maven.lifecycle.DefaultLifecycleExecutor.execute(DefaultLifecycleExecutor.java:180)
> at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:328)
> at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:138)
> at org.apache.maven.cli.MavenCli.main(MavenCli.java:362)
> at
> org.apache.maven.cli.compat.CompatibleMain.main(CompatibleMain.java:60)
> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> at
> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
> at
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
> at java.lang.reflect.Method.invoke(Method.java:597)
> at org.codehaus.classworlds.Launcher.launchEnhanced(Launcher.java:315)
> at org.codehaus.classworlds.Launcher.launch(Launcher.java:255)
> at
> org.codehaus.classworlds.Launcher.mainWithExitCode(Launcher.java:430)
> at org.codehaus.classworlds.Launcher.main(Launcher.java:375)
> The problem seems to be an exact replica of this bug for ant sql exec:
> https://issues.apache.org/bugzilla/show_bug.cgi?id=36265
> I made a local patch of Maven Sql plugin using the fix in the ant sql bug
> report and this solved the problem.
> (The patch conforms to my local coding standards so unfortunately has lots of
> trivial changes. You may prefer to make the change directly to the code
> yourselves)
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
http://jira.codehaus.org/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
---------------------------------------------------------------------
To unsubscribe from this list, please visit:
http://xircles.codehaus.org/manage_email