MySQL Forums
Forum List  »  Connector/JDBC and Java

Get SHOW WARNINGS stacktrace after calling a LOAD DATA command through Connector/J
Posted by: Jacques Barney
Date: March 13, 2013 03:01PM

Hi,

Is there a way to retrieve the SHOW WARNINGS stacktrace after calling a LOAD DATA command through Connector/J? If you look at the method below, I'd like to to do something like the commented out part. Actually, I'd rather redirect it to a file on disk, like tee does, but can redirect it from here easily enough.

@Override
public final void importData( final SrcFile srcFile, final String filePath )
throws FileNotFoundException, IOException, SQLException{

Connection con=null;
Statement stmt=null;
InputStream is=null;
try{
con=this.mySqlConnection.getRawConnection();
stmt=(com.mysql.jdbc.Statement)con.createStatement();
is=new FileInputStream( filePath );
if( con.isServerLocal() )
stmt.setLocalInfileInputStream( is );
if( !stmt.execute( command ) ){
logger.error( '['+this.getClass().getName()+"] SQL command:"+command );
}
else if( logger.isDebugEnabled() )
logger.debug( '['+this.getClass().getName()+"] SQL command:"+command );
/*
final ResultSet rs=stmt.executeQuery( "SHOW WARNINGS;" );
logger.warn( '['+this.getClass().getName()+"] : SHOW WARNINGS" );
while( rs.next() ){
logger.warn( '['+this.getClass().getName()+"] :"+rs.getString(1) );
logger.warn( '['+this.getClass().getName()+"] :"+rs.getString(2) );
logger.warn( '['+this.getClass().getName()+"] :"+rs.getString(3) );
}
rs.close();
*/
}
catch( final FileNotFoundException e ){ throw e; }
catch( final SQLException e ){
logger.error( '['+this.getClass().getName()+"] SQL command:"+command );
throw e;
}
finally{
if( stmt!=null ) stmt.close();
if( con!=null ) con.close();
if( is!=null ) is.close();
}

Thank you,
Jack

Options: ReplyQuote


Subject
Written By
Posted
Get SHOW WARNINGS stacktrace after calling a LOAD DATA command through Connector/J
March 13, 2013 03:01PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.