View Javadoc
1 package com.internetcds.jdbc.tds; 2 3 import java.sql.SQLException; 4 import java.sql.SQLWarning; 5 6 /*** 7 * Helper class to redruce duplicated code. 8 * 9 * @author Stefan Bodewig <a href="mailto:stefan.bodewig@megabit.net">stefan.bodewig@megabit.net</a> 10 * 11 * @version $Id: SQLWarningChain.java,v 1.1 2003/04/29 18:07:50 sinisa Exp $ 12 */ 13 class SQLWarningChain { 14 public static final String cvsVersion = "$Id: SQLWarningChain.java,v 1.1 2003/04/29 18:07:50 sinisa Exp $"; 15 16 private SQLWarning warnings; 17 18 SQLWarningChain () 19 { 20 warnings = null; 21 } 22 23 /*** 24 * The first warning added with {@see #addWarning addWarning}. 25 * Subsequent warnings will be chained to this SQLWarning. 26 */ 27 synchronized SQLWarning getWarnings() { 28 return warnings; 29 } 30 31 /*** 32 * After this call {@see #getWarnings getWarnings} returns null 33 * until {@see #addWarning addWarning} has been called again. 34 */ 35 synchronized void clearWarnings() { 36 warnings = null; 37 } 38 39 /*** 40 * Adds a SQLWarning to the warning chain. 41 */ 42 synchronized void addWarning(SQLWarning warn) { 43 if (warnings == null) { 44 warnings = warn; 45 } else { 46 warnings.setNextWarning(warn); 47 } 48 } 49 50 /*** 51 * Adds the SQLWarning wrapped in the packet if it's not an ErrorResult. 52 * Returns the wrapped SQLException otherwise. 53 */ 54 SQLException addOrReturn(PacketMsgResult pack) { 55 if (pack instanceof PacketErrorResult) { 56 return pack.getMsg().toSQLException(); 57 } else { 58 addWarning(pack.getMsg().toSQLWarning()); 59 return null; 60 } 61 } 62 } 63

This page was automatically generated by Maven