Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 29ea8ff

Browse files
author
Dave Cramer
committed
Patch by Nicolas Verger to correctly propogate SQLWarning to the Statement and ResultSet
1 parent ff2f9b6 commit 29ea8ff

File tree

2 files changed

+44
-0
lines changed

2 files changed

+44
-0
lines changed

src/interfaces/jdbc/org/postgresql/ResultSet.java

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -223,5 +223,37 @@ public String getFixedString(int col) throws SQLException
223223

224224
return s;
225225
}
226+
227+
/**
228+
* The first warning reported by calls on this ResultSet is
229+
* returned. Subsequent ResultSet warnings will be chained
230+
* to this SQLWarning.
231+
*
232+
* <p>The warning chain is automatically cleared each time a new
233+
* row is read.
234+
*
235+
* <p><B>Note:</B> This warning chain only covers warnings caused by
236+
* ResultSet methods. Any warnings caused by statement methods
237+
* (such as reading OUT parameters) will be chained on the
238+
* Statement object.
239+
*
240+
* @return the first SQLWarning or null;
241+
* @exception SQLException if a database access error occurs.
242+
*/
243+
public SQLWarning getWarnings() throws SQLException
244+
{
245+
return warnings;
246+
}
247+
248+
/**
249+
* Add a warning chain to the current warning chain
250+
* @param warnings warnings to add
251+
*/
252+
public void addWarnings(SQLWarning warnings) {
253+
if ( this.warnings != null )
254+
this.warnings.setNextWarning(warnings);
255+
else
256+
this.warnings = warnings;
257+
}
226258
}
227259

src/interfaces/jdbc/org/postgresql/Statement.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,18 @@ public void setQueryTimeout(int seconds) throws SQLException
110110
timeout = seconds;
111111
}
112112

113+
/**
114+
* This adds a warning to the warning chain.
115+
* @param msg message to add
116+
*/
117+
public void addWarning(String msg)
118+
{
119+
if (warnings != null)
120+
warnings.setNextWarning(new SQLWarning(msg));
121+
else
122+
warnings = new SQLWarning(msg);
123+
}
124+
113125
/*
114126
* The first warning reported by calls on this Statement is
115127
* returned. A Statement's execute methods clear its SQLWarning

0 commit comments

Comments
 (0)