source: proiecte/HadoopJUnit/hadoop-0.20.1/docs/api/org/apache/hadoop/mapred/lib/db/DBWritable.html @ 120

Last change on this file since 120 was 120, checked in by (none), 14 years ago

Added the mail files for the Hadoop JUNit Project

  • Property svn:executable set to *
File size: 13.1 KB
Line 
1<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
2<!--NewPage-->
3<HTML>
4<HEAD>
5<!-- Generated by javadoc (build 1.6.0_07) on Tue Sep 01 20:56:58 UTC 2009 -->
6<TITLE>
7DBWritable (Hadoop 0.20.1 API)
8</TITLE>
9
10<META NAME="date" CONTENT="2009-09-01">
11
12<LINK REL ="stylesheet" TYPE="text/css" HREF="../../../../../../stylesheet.css" TITLE="Style">
13
14<SCRIPT type="text/javascript">
15function windowTitle()
16{
17    if (location.href.indexOf('is-external=true') == -1) {
18        parent.document.title="DBWritable (Hadoop 0.20.1 API)";
19    }
20}
21</SCRIPT>
22<NOSCRIPT>
23</NOSCRIPT>
24
25</HEAD>
26
27<BODY BGCOLOR="white" onload="windowTitle();">
28<HR>
29
30
31<!-- ========= START OF TOP NAVBAR ======= -->
32<A NAME="navbar_top"><!-- --></A>
33<A HREF="#skip-navbar_top" title="Skip navigation links"></A>
34<TABLE BORDER="0" WIDTH="100%" CELLPADDING="1" CELLSPACING="0" SUMMARY="">
35<TR>
36<TD COLSPAN=2 BGCOLOR="#EEEEFF" CLASS="NavBarCell1">
37<A NAME="navbar_top_firstrow"><!-- --></A>
38<TABLE BORDER="0" CELLPADDING="0" CELLSPACING="3" SUMMARY="">
39  <TR ALIGN="center" VALIGN="top">
40  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="../../../../../../overview-summary.html"><FONT CLASS="NavBarFont1"><B>Overview</B></FONT></A>&nbsp;</TD>
41  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="package-summary.html"><FONT CLASS="NavBarFont1"><B>Package</B></FONT></A>&nbsp;</TD>
42  <TD BGCOLOR="#FFFFFF" CLASS="NavBarCell1Rev"> &nbsp;<FONT CLASS="NavBarFont1Rev"><B>Class</B></FONT>&nbsp;</TD>
43  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="class-use/DBWritable.html"><FONT CLASS="NavBarFont1"><B>Use</B></FONT></A>&nbsp;</TD>
44  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="package-tree.html"><FONT CLASS="NavBarFont1"><B>Tree</B></FONT></A>&nbsp;</TD>
45  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="../../../../../../deprecated-list.html"><FONT CLASS="NavBarFont1"><B>Deprecated</B></FONT></A>&nbsp;</TD>
46  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="../../../../../../index-all.html"><FONT CLASS="NavBarFont1"><B>Index</B></FONT></A>&nbsp;</TD>
47  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="../../../../../../help-doc.html"><FONT CLASS="NavBarFont1"><B>Help</B></FONT></A>&nbsp;</TD>
48  </TR>
49</TABLE>
50</TD>
51<TD ALIGN="right" VALIGN="top" ROWSPAN=3><EM>
52</EM>
53</TD>
54</TR>
55
56<TR>
57<TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2">
58&nbsp;<A HREF="../../../../../../org/apache/hadoop/mapred/lib/db/DBOutputFormat.DBRecordWriter.html" title="class in org.apache.hadoop.mapred.lib.db"><B>PREV CLASS</B></A>&nbsp;
59&nbsp;NEXT CLASS</FONT></TD>
60<TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2">
61  <A HREF="../../../../../../index.html?org/apache/hadoop/mapred/lib/db/DBWritable.html" target="_top"><B>FRAMES</B></A>  &nbsp;
62&nbsp;<A HREF="DBWritable.html" target="_top"><B>NO FRAMES</B></A>  &nbsp;
63&nbsp;<SCRIPT type="text/javascript">
64  <!--
65  if(window==top) {
66    document.writeln('<A HREF="../../../../../../allclasses-noframe.html"><B>All Classes</B></A>');
67  }
68  //-->
69</SCRIPT>
70<NOSCRIPT>
71  <A HREF="../../../../../../allclasses-noframe.html"><B>All Classes</B></A>
72</NOSCRIPT>
73
74
75</FONT></TD>
76</TR>
77<TR>
78<TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2">
79  SUMMARY:&nbsp;NESTED&nbsp;|&nbsp;FIELD&nbsp;|&nbsp;CONSTR&nbsp;|&nbsp;<A HREF="#method_summary">METHOD</A></FONT></TD>
80<TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2">
81DETAIL:&nbsp;FIELD&nbsp;|&nbsp;CONSTR&nbsp;|&nbsp;<A HREF="#method_detail">METHOD</A></FONT></TD>
82</TR>
83</TABLE>
84<A NAME="skip-navbar_top"></A>
85<!-- ========= END OF TOP NAVBAR ========= -->
86
87<HR>
88<!-- ======== START OF CLASS DATA ======== -->
89<H2>
90<FONT SIZE="-1">
91org.apache.hadoop.mapred.lib.db</FONT>
92<BR>
93Interface DBWritable</H2>
94<DL>
95<DT><B>All Known Implementing Classes:</B> <DD><A HREF="../../../../../../org/apache/hadoop/mapred/lib/db/DBInputFormat.NullDBWritable.html" title="class in org.apache.hadoop.mapred.lib.db">DBInputFormat.NullDBWritable</A></DD>
96</DL>
97<HR>
98<DL>
99<DT><PRE>public interface <B>DBWritable</B></DL>
100</PRE>
101
102<P>
103Objects that are read from/written to a database should implement
104 <code>DBWritable</code>. DBWritable, is similar to <A HREF="../../../../../../org/apache/hadoop/io/Writable.html" title="interface in org.apache.hadoop.io"><CODE>Writable</CODE></A> 
105 except that the <A HREF="../../../../../../org/apache/hadoop/mapred/lib/db/DBWritable.html#write(java.sql.PreparedStatement)"><CODE>write(PreparedStatement)</CODE></A> method takes a
106 <A HREF="http://java.sun.com/javase/6/docs/api/java/sql/PreparedStatement.html?is-external=true" title="class or interface in java.sql"><CODE>PreparedStatement</CODE></A>, and <A HREF="../../../../../../org/apache/hadoop/mapred/lib/db/DBWritable.html#readFields(java.sql.ResultSet)"><CODE>readFields(ResultSet)</CODE></A> 
107 takes a <A HREF="http://java.sun.com/javase/6/docs/api/java/sql/ResultSet.html?is-external=true" title="class or interface in java.sql"><CODE>ResultSet</CODE></A>.
108 <p>
109 Implementations are responsible for writing the fields of the object
110 to PreparedStatement, and reading the fields of the object from the
111 ResultSet.
112 
113 <p>Example:</p>
114 If we have the following table in the database :
115 <pre>
116 CREATE TABLE MyTable (
117   counter        INTEGER NOT NULL,
118   timestamp      BIGINT  NOT NULL,
119 );
120 </pre>
121 then we can read/write the tuples from/to the table with :
122 <p><pre>
123 public class MyWritable implements Writable, DBWritable {
124   // Some data     
125   private int counter;
126   private long timestamp;
127       
128   //Writable#write() implementation
129   public void write(DataOutput out) throws IOException {
130     out.writeInt(counter);
131     out.writeLong(timestamp);
132   }
133       
134   //Writable#readFields() implementation
135   public void readFields(DataInput in) throws IOException {
136     counter = in.readInt();
137     timestamp = in.readLong();
138   }
139       
140   public void write(PreparedStatement statement) throws SQLException {
141     statement.setInt(1, counter);
142     statement.setLong(2, timestamp);
143   }
144       
145   public void readFields(ResultSet resultSet) throws SQLException {
146     counter = resultSet.getInt(1);
147     timestamp = resultSet.getLong(2);
148   }
149 }
150 </pre></p>
151<P>
152
153<P>
154<HR>
155
156<P>
157
158<!-- ========== METHOD SUMMARY =========== -->
159
160<A NAME="method_summary"><!-- --></A>
161<TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY="">
162<TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor">
163<TH ALIGN="left" COLSPAN="2"><FONT SIZE="+2">
164<B>Method Summary</B></FONT></TH>
165</TR>
166<TR BGCOLOR="white" CLASS="TableRowColor">
167<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
168<CODE>&nbsp;void</CODE></FONT></TD>
169<TD><CODE><B><A HREF="../../../../../../org/apache/hadoop/mapred/lib/db/DBWritable.html#readFields(java.sql.ResultSet)">readFields</A></B>(<A HREF="http://java.sun.com/javase/6/docs/api/java/sql/ResultSet.html?is-external=true" title="class or interface in java.sql">ResultSet</A>&nbsp;resultSet)</CODE>
170
171<BR>
172&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Reads the fields of the object from the <A HREF="http://java.sun.com/javase/6/docs/api/java/sql/ResultSet.html?is-external=true" title="class or interface in java.sql"><CODE>ResultSet</CODE></A>.</TD>
173</TR>
174<TR BGCOLOR="white" CLASS="TableRowColor">
175<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
176<CODE>&nbsp;void</CODE></FONT></TD>
177<TD><CODE><B><A HREF="../../../../../../org/apache/hadoop/mapred/lib/db/DBWritable.html#write(java.sql.PreparedStatement)">write</A></B>(<A HREF="http://java.sun.com/javase/6/docs/api/java/sql/PreparedStatement.html?is-external=true" title="class or interface in java.sql">PreparedStatement</A>&nbsp;statement)</CODE>
178
179<BR>
180&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Sets the fields of the object in the <A HREF="http://java.sun.com/javase/6/docs/api/java/sql/PreparedStatement.html?is-external=true" title="class or interface in java.sql"><CODE>PreparedStatement</CODE></A>.</TD>
181</TR>
182</TABLE>
183&nbsp;
184<P>
185
186<!-- ============ METHOD DETAIL ========== -->
187
188<A NAME="method_detail"><!-- --></A>
189<TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY="">
190<TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor">
191<TH ALIGN="left" COLSPAN="1"><FONT SIZE="+2">
192<B>Method Detail</B></FONT></TH>
193</TR>
194</TABLE>
195
196<A NAME="write(java.sql.PreparedStatement)"><!-- --></A><H3>
197write</H3>
198<PRE>
199void <B>write</B>(<A HREF="http://java.sun.com/javase/6/docs/api/java/sql/PreparedStatement.html?is-external=true" title="class or interface in java.sql">PreparedStatement</A>&nbsp;statement)
200           throws <A HREF="http://java.sun.com/javase/6/docs/api/java/sql/SQLException.html?is-external=true" title="class or interface in java.sql">SQLException</A></PRE>
201<DL>
202<DD>Sets the fields of the object in the <A HREF="http://java.sun.com/javase/6/docs/api/java/sql/PreparedStatement.html?is-external=true" title="class or interface in java.sql"><CODE>PreparedStatement</CODE></A>.
203<P>
204<DD><DL>
205<DT><B>Parameters:</B><DD><CODE>statement</CODE> - the statement that the fields are put into.
206<DT><B>Throws:</B>
207<DD><CODE><A HREF="http://java.sun.com/javase/6/docs/api/java/sql/SQLException.html?is-external=true" title="class or interface in java.sql">SQLException</A></CODE></DL>
208</DD>
209</DL>
210<HR>
211
212<A NAME="readFields(java.sql.ResultSet)"><!-- --></A><H3>
213readFields</H3>
214<PRE>
215void <B>readFields</B>(<A HREF="http://java.sun.com/javase/6/docs/api/java/sql/ResultSet.html?is-external=true" title="class or interface in java.sql">ResultSet</A>&nbsp;resultSet)
216                throws <A HREF="http://java.sun.com/javase/6/docs/api/java/sql/SQLException.html?is-external=true" title="class or interface in java.sql">SQLException</A></PRE>
217<DL>
218<DD>Reads the fields of the object from the <A HREF="http://java.sun.com/javase/6/docs/api/java/sql/ResultSet.html?is-external=true" title="class or interface in java.sql"><CODE>ResultSet</CODE></A>.
219<P>
220<DD><DL>
221<DT><B>Parameters:</B><DD><CODE>resultSet</CODE> - the <A HREF="http://java.sun.com/javase/6/docs/api/java/sql/ResultSet.html?is-external=true" title="class or interface in java.sql"><CODE>ResultSet</CODE></A> to get the fields from.
222<DT><B>Throws:</B>
223<DD><CODE><A HREF="http://java.sun.com/javase/6/docs/api/java/sql/SQLException.html?is-external=true" title="class or interface in java.sql">SQLException</A></CODE></DL>
224</DD>
225</DL>
226<!-- ========= END OF CLASS DATA ========= -->
227<HR>
228
229
230<!-- ======= START OF BOTTOM NAVBAR ====== -->
231<A NAME="navbar_bottom"><!-- --></A>
232<A HREF="#skip-navbar_bottom" title="Skip navigation links"></A>
233<TABLE BORDER="0" WIDTH="100%" CELLPADDING="1" CELLSPACING="0" SUMMARY="">
234<TR>
235<TD COLSPAN=2 BGCOLOR="#EEEEFF" CLASS="NavBarCell1">
236<A NAME="navbar_bottom_firstrow"><!-- --></A>
237<TABLE BORDER="0" CELLPADDING="0" CELLSPACING="3" SUMMARY="">
238  <TR ALIGN="center" VALIGN="top">
239  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="../../../../../../overview-summary.html"><FONT CLASS="NavBarFont1"><B>Overview</B></FONT></A>&nbsp;</TD>
240  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="package-summary.html"><FONT CLASS="NavBarFont1"><B>Package</B></FONT></A>&nbsp;</TD>
241  <TD BGCOLOR="#FFFFFF" CLASS="NavBarCell1Rev"> &nbsp;<FONT CLASS="NavBarFont1Rev"><B>Class</B></FONT>&nbsp;</TD>
242  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="class-use/DBWritable.html"><FONT CLASS="NavBarFont1"><B>Use</B></FONT></A>&nbsp;</TD>
243  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="package-tree.html"><FONT CLASS="NavBarFont1"><B>Tree</B></FONT></A>&nbsp;</TD>
244  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="../../../../../../deprecated-list.html"><FONT CLASS="NavBarFont1"><B>Deprecated</B></FONT></A>&nbsp;</TD>
245  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="../../../../../../index-all.html"><FONT CLASS="NavBarFont1"><B>Index</B></FONT></A>&nbsp;</TD>
246  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="../../../../../../help-doc.html"><FONT CLASS="NavBarFont1"><B>Help</B></FONT></A>&nbsp;</TD>
247  </TR>
248</TABLE>
249</TD>
250<TD ALIGN="right" VALIGN="top" ROWSPAN=3><EM>
251</EM>
252</TD>
253</TR>
254
255<TR>
256<TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2">
257&nbsp;<A HREF="../../../../../../org/apache/hadoop/mapred/lib/db/DBOutputFormat.DBRecordWriter.html" title="class in org.apache.hadoop.mapred.lib.db"><B>PREV CLASS</B></A>&nbsp;
258&nbsp;NEXT CLASS</FONT></TD>
259<TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2">
260  <A HREF="../../../../../../index.html?org/apache/hadoop/mapred/lib/db/DBWritable.html" target="_top"><B>FRAMES</B></A>  &nbsp;
261&nbsp;<A HREF="DBWritable.html" target="_top"><B>NO FRAMES</B></A>  &nbsp;
262&nbsp;<SCRIPT type="text/javascript">
263  <!--
264  if(window==top) {
265    document.writeln('<A HREF="../../../../../../allclasses-noframe.html"><B>All Classes</B></A>');
266  }
267  //-->
268</SCRIPT>
269<NOSCRIPT>
270  <A HREF="../../../../../../allclasses-noframe.html"><B>All Classes</B></A>
271</NOSCRIPT>
272
273
274</FONT></TD>
275</TR>
276<TR>
277<TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2">
278  SUMMARY:&nbsp;NESTED&nbsp;|&nbsp;FIELD&nbsp;|&nbsp;CONSTR&nbsp;|&nbsp;<A HREF="#method_summary">METHOD</A></FONT></TD>
279<TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2">
280DETAIL:&nbsp;FIELD&nbsp;|&nbsp;CONSTR&nbsp;|&nbsp;<A HREF="#method_detail">METHOD</A></FONT></TD>
281</TR>
282</TABLE>
283<A NAME="skip-navbar_bottom"></A>
284<!-- ======== END OF BOTTOM NAVBAR ======= -->
285
286<HR>
287Copyright &copy; 2009 The Apache Software Foundation
288</BODY>
289</HTML>
Note: See TracBrowser for help on using the repository browser.