⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 dbinserter.html

📁 Medi 这是一个基于Java的媒体文件归档器工具
💻 HTML
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN""http://www.w3.org/TR/REC-html40/loose.dtd"><!--NewPage--><HTML><HEAD><!-- Generated by javadoc on Wed Jan 15 11:28:12 CET 2003 --><TITLE>DbInserter</TITLE><META NAME="keywords" CONTENT="javatools.db.DbInserter,DbInserter class"><LINK REL ="stylesheet" TYPE="text/css" HREF="../../stylesheet.css" TITLE="Style"></HEAD><SCRIPT>function asd(){parent.document.title="DbInserter";}</SCRIPT><BODY BGCOLOR="white" onload="asd();"><!-- ========== START OF NAVBAR ========== --><A NAME="navbar_top"><!-- --></A><TABLE BORDER="0" WIDTH="100%" CELLPADDING="1" CELLSPACING="0"><TR><TD COLSPAN=3 BGCOLOR="#EEEEFF" CLASS="NavBarCell1"><A NAME="navbar_top_firstrow"><!-- --></A><TABLE BORDER="0" CELLPADDING="0" CELLSPACING="3">  <TR ALIGN="center" VALIGN="top">  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="../../overview-summary.html"><FONT CLASS="NavBarFont1"><B>Overview</B></FONT></A>&nbsp;</TD>  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="package-summary.html"><FONT CLASS="NavBarFont1"><B>Package</B></FONT></A>&nbsp;</TD>  <TD BGCOLOR="#FFFFFF" CLASS="NavBarCell1Rev"> &nbsp;<FONT CLASS="NavBarFont1Rev"><B>Class</B></FONT>&nbsp;</TD>  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="package-tree.html"><FONT CLASS="NavBarFont1"><B>Tree</B></FONT></A>&nbsp;</TD>  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="../../deprecated-list.html"><FONT CLASS="NavBarFont1"><B>Deprecated</B></FONT></A>&nbsp;</TD>  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="../../index-all.html"><FONT CLASS="NavBarFont1"><B>Index</B></FONT></A>&nbsp;</TD>  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="../../help-doc.html"><FONT CLASS="NavBarFont1"><B>Help</B></FONT></A>&nbsp;</TD>  </TR></TABLE></TD><TD ALIGN="right" VALIGN="top" ROWSPAN=3><EM></EM></TD></TR><TR><TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2">&nbsp;<A HREF="../../javatools/db/DbFixedAbstractTable.html"><B>PREV CLASS</B></A>&nbsp;&nbsp;<A HREF="../../javatools/db/DbIterator.html"><B>NEXT CLASS</B></A></FONT></TD><TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2">  <A HREF="../../index.html" TARGET="_top"><B>FRAMES</B></A>  &nbsp;&nbsp;<A HREF="DbInserter.html" TARGET="_top"><B>NO FRAMES</B></A>  &nbsp;&nbsp;<SCRIPT>  <!--  if(window==top) {    document.writeln('<A HREF="../../allclasses-noframe.html" TARGET=""><B>All Classes</B></A>');  }  //--></SCRIPT><NOSCRIPT><A HREF="../../allclasses-noframe.html" TARGET=""><B>All Classes</B></A></NOSCRIPT></FONT></TD></TR><TR><TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2">  SUMMARY:&nbsp;NESTED&nbsp;|&nbsp;FIELD&nbsp;|&nbsp;CONSTR&nbsp;|&nbsp;<A HREF="#method_summary">METHOD</A></FONT></TD><TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2">DETAIL:&nbsp;FIELD&nbsp;|&nbsp;CONSTR&nbsp;|&nbsp;<A HREF="#method_detail">METHOD</A></FONT></TD></TR></TABLE><!-- =========== END OF NAVBAR =========== --><HR><!-- ======== START OF CLASS DATA ======== --><H2><FONT SIZE="-1">javatools.db</FONT><BR>Class DbInserter</H2><PRE>java.lang.Object  |  +--<B>javatools.db.DbInserter</B></PRE><DL><DT><B>Direct Known Subclasses:</B> <DD><A HREF="../../javatools/db/DbReferencedInserter.html">DbReferencedInserter</A></DD></DL><HR><DL><DT>public class <B>DbInserter</B><DT>extends java.lang.Object</DL><P>A class used to insert records into SQL tables. The constructor is not public. To obtain a DbInserter call DbTable.inserter(); Example: To insert a record into the people table... <PRE> DbDatabase db = ...; DbTable people = db.getTable("PEOPLE"); DbInserter inserter = people.inserter(); inserter.addColumn(people.getColumn("NAME"), "Fred")); inserter.addColumn(people.getColumn("FAVOURITE_TEAM"), "Raiders"); inserter.addColumn(people.getColumn("AGE"), new Integer(30)); int numberOfPeopleInserted = inserter.execute(); </PRE> This is equivilent to... <PRE> INSERT INTO PEOPLE(NAME, FAVOURITE_TEAM, AGE) VALUES('Fred', 'Raiders', 30) </PRE> The same thing as above can be achieved using a SELECT clause, and this can lead us to creating much more complex expressions... <PRE> DbDatabase db = ...; DbSelector selector = db.selector(); DbTable people = db.getTable("PEOPLE"); DbInserter inserter = people.inserter(selector); inserter.addColumn(people.getColumn("NAME"), selector.addColumn("Fred"))); inserter.addColumn(people.getColumn("FAVOURITE_TEAM"), selector.addColumn("Raiders")); inserter.addColumn(people.getColumn("AGE"), selector.addColumn(new Integer(30))); int numberOfPeopleInserted = inserter.execute(); </PRE> This is equivilent to... <PRE> INSERT INTO PEOPLE(NAME, FAVOURITE_TEAM, AGE) SELECT 'Fred', 'Raiders', 30 </PRE> To get more fancy we can insert data that has been selected from another table. To insert all the people from the PLAYERS table into the PEOPLE table who are older than 20, and we set their favourite team to be the team they play for... <PRE> DbDatabase db = ...; DbSelector selector = db.selector(); DbTable people = db.getTable("PEOPLE"); DbTable players = db.getTable("PLAYERS"); DbInserter inserter = people.inserter(selector); inserter.addColumn(people.getColumn("NAME"), selector.addColumn(players.getColumn("NAME"))); inserter.addColumn(people.getColumn("FAVOURITE_TEAM"), selector.addColumn(players.getColumn("TEAM"))); inserter.addColumn(people.getColumn("AGE"), selector.addColumn(players.getColumn("AGE"))); selector.setWhere(players.getColumn("AGE").greaterThan(new Integer(20))); int numberOfPeopleInserted = inserter.execute(); </PRE> This is equivilent to... <PRE> INSERT INTO PEOPLE(NAME, FAVOURITE_TEAM, AGE) SELECT NAME, TEAM, AGE FROM PLAYERS WHERE AGE > 20 </PRE><P><P><HR><P><!-- ======== NESTED CLASS SUMMARY ======== --><!-- =========== FIELD SUMMARY =========== --><!-- ======== CONSTRUCTOR SUMMARY ======== --><!-- ========== METHOD SUMMARY =========== --><A NAME="method_summary"><!-- --></A><TABLE BORDER="1" CELLPADDING="3" CELLSPACING="0" WIDTH="100%"><TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor"><TD COLSPAN=2><FONT SIZE="+2"><B>Method Summary</B></FONT></TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE>&nbsp;void</CODE></FONT></TD><TD><CODE><B><A HREF="../../javatools/db/DbInserter.html#addColumn(javatools.db.DbColumn, java.lang.Object)">addColumn</A></B>(<A HREF="../../javatools/db/DbColumn.html">DbColumn</A>&nbsp;into,          java.lang.Object&nbsp;from)</CODE><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Specify the value of a column to add.</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE>&nbsp;int</CODE></FONT></TD><TD><CODE><B><A HREF="../../javatools/db/DbInserter.html#execute()">execute</A></B>()</CODE><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Execute this command on the default connection.</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE>&nbsp;int</CODE></FONT></TD><TD><CODE><B><A HREF="../../javatools/db/DbInserter.html#execute(javatools.db.DbConnection)">execute</A></B>(<A HREF="../../javatools/db/DbConnection.html">DbConnection</A>&nbsp;dbcon)</CODE><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Execute this command on a specific connection.</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE>&nbsp;void</CODE></FONT></TD><TD><CODE><B><A HREF="../../javatools/db/DbInserter.html#setLists(java.util.List, java.util.List)">setLists</A></B>(java.util.List&nbsp;pIntoList,         java.util.List&nbsp;pFromList)</CODE><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Directly sets intoList and fromList.</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE>&nbsp;int</CODE></FONT></TD><TD><CODE><B><A HREF="../../javatools/db/DbInserter.html#setSqlValues(java.sql.PreparedStatement, int)">setSqlValues</A></B>(java.sql.PreparedStatement&nbsp;stmt,             int&nbsp;i)</CODE><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Puts data into a prepared statement.</TD></TR></TABLE>&nbsp;<A NAME="methods_inherited_from_class_java.lang.Object"><!-- --></A><TABLE BORDER="1" CELLPADDING="3" CELLSPACING="0" WIDTH="100%"><TR BGCOLOR="#EEEEFF" CLASS="TableSubHeadingColor"><TD><B>Methods inherited from class java.lang.Object</B></TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD><CODE>clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait</CODE></TD></TR></TABLE>&nbsp;<P><!-- ============ FIELD DETAIL =========== --><!-- ========= CONSTRUCTOR DETAIL ======== --><!-- ============ METHOD DETAIL ========== --><A NAME="method_detail"><!-- --></A><TABLE BORDER="1" CELLPADDING="3" CELLSPACING="0" WIDTH="100%"><TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor"><TD COLSPAN=1><FONT SIZE="+2"><B>Method Detail</B></FONT></TD></TR></TABLE><A NAME="setSqlValues(java.sql.PreparedStatement, int)"><!-- --></A><H3>setSqlValues</H3><PRE>public int <B>setSqlValues</B>(java.sql.PreparedStatement&nbsp;stmt,                        int&nbsp;i)                 throws <A HREF="../../javatools/db/DbException.html">DbException</A>,                        java.sql.SQLException</PRE><DL><DD>Puts data into a prepared statement.<P><DD><DL><DT><B>Parameters:</B><DD><CODE>stmt</CODE> - The prepared statement.<DD><CODE>i</CODE> - An index (obscure).<DT><B>Returns:</B><DD>An index, obscure.<DT><B>Throws:</B><DD><CODE><A HREF="../../javatools/db/DbException.html">DbException</A></CODE> - If something goes wrong.<DD><CODE>java.sql.SQLException</CODE> - If something goes wrong.</DL></DD></DL><HR><A NAME="addColumn(javatools.db.DbColumn, java.lang.Object)"><!-- --></A><H3>addColumn</H3><PRE>public void <B>addColumn</B>(<A HREF="../../javatools/db/DbColumn.html">DbColumn</A>&nbsp;into,                      java.lang.Object&nbsp;from)</PRE><DL><DD>Specify the value of a column to add.<P><DD><DL><DT><B>Parameters:</B><DD><CODE>into</CODE> - The column we are inserting into.<DD><CODE>from</CODE> - The column from a selector that we are getting a value from.</DL></DD></DL><HR><A NAME="setLists(java.util.List, java.util.List)"><!-- --></A><H3>setLists</H3><PRE>public void <B>setLists</B>(java.util.List&nbsp;pIntoList,                     java.util.List&nbsp;pFromList)</PRE><DL><DD>Directly sets intoList and fromList.<P><DD><DL><DT><B>Parameters:</B><DD><CODE>pIntoList</CODE> - The list containing the columns to put data into.<DD><CODE>pFromList</CODE> - The list containing the data that will be put.</DL></DD></DL><HR><A NAME="execute(javatools.db.DbConnection)"><!-- --></A><H3>execute</H3><PRE>public int <B>execute</B>(<A HREF="../../javatools/db/DbConnection.html">DbConnection</A>&nbsp;dbcon)            throws <A HREF="../../javatools/db/DbException.html">DbException</A></PRE><DL><DD>Execute this command on a specific connection.<P><DD><DL><DT><B>Parameters:</B><DD><CODE>dbcon</CODE> - The connection to use.<DT><B>Returns:</B><DD>The number of record affected.<DT><B>Throws:</B><DD><CODE><A HREF="../../javatools/db/DbException.html">DbException</A></CODE> - If something goes wrong.</DL></DD></DL><HR><A NAME="execute()"><!-- --></A><H3>execute</H3><PRE>public int <B>execute</B>()            throws <A HREF="../../javatools/db/DbException.html">DbException</A></PRE><DL><DD>Execute this command on the default connection.<P><DD><DL><DT><B>Returns:</B><DD>The number of record affected.<DT><B>Throws:</B><DD><CODE><A HREF="../../javatools/db/DbException.html">DbException</A></CODE> - If something goes wrong.</DL></DD></DL><!-- ========= END OF CLASS DATA ========= --><HR><!-- ========== START OF NAVBAR ========== --><A NAME="navbar_bottom"><!-- --></A><TABLE BORDER="0" WIDTH="100%" CELLPADDING="1" CELLSPACING="0"><TR><TD COLSPAN=3 BGCOLOR="#EEEEFF" CLASS="NavBarCell1"><A NAME="navbar_bottom_firstrow"><!-- --></A><TABLE BORDER="0" CELLPADDING="0" CELLSPACING="3">  <TR ALIGN="center" VALIGN="top">  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="../../overview-summary.html"><FONT CLASS="NavBarFont1"><B>Overview</B></FONT></A>&nbsp;</TD>  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="package-summary.html"><FONT CLASS="NavBarFont1"><B>Package</B></FONT></A>&nbsp;</TD>  <TD BGCOLOR="#FFFFFF" CLASS="NavBarCell1Rev"> &nbsp;<FONT CLASS="NavBarFont1Rev"><B>Class</B></FONT>&nbsp;</TD>  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="package-tree.html"><FONT CLASS="NavBarFont1"><B>Tree</B></FONT></A>&nbsp;</TD>  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="../../deprecated-list.html"><FONT CLASS="NavBarFont1"><B>Deprecated</B></FONT></A>&nbsp;</TD>  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="../../index-all.html"><FONT CLASS="NavBarFont1"><B>Index</B></FONT></A>&nbsp;</TD>  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="../../help-doc.html"><FONT CLASS="NavBarFont1"><B>Help</B></FONT></A>&nbsp;</TD>  </TR></TABLE></TD><TD ALIGN="right" VALIGN="top" ROWSPAN=3><EM></EM></TD></TR><TR><TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2">&nbsp;<A HREF="../../javatools/db/DbFixedAbstractTable.html"><B>PREV CLASS</B></A>&nbsp;&nbsp;<A HREF="../../javatools/db/DbIterator.html"><B>NEXT CLASS</B></A></FONT></TD><TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2">  <A HREF="../../index.html" TARGET="_top"><B>FRAMES</B></A>  &nbsp;&nbsp;<A HREF="DbInserter.html" TARGET="_top"><B>NO FRAMES</B></A>  &nbsp;&nbsp;<SCRIPT>  <!--  if(window==top) {    document.writeln('<A HREF="../../allclasses-noframe.html" TARGET=""><B>All Classes</B></A>');  }  //--></SCRIPT><NOSCRIPT><A HREF="../../allclasses-noframe.html" TARGET=""><B>All Classes</B></A></NOSCRIPT></FONT></TD></TR><TR><TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2">  SUMMARY:&nbsp;NESTED&nbsp;|&nbsp;FIELD&nbsp;|&nbsp;CONSTR&nbsp;|&nbsp;<A HREF="#method_summary">METHOD</A></FONT></TD><TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2">DETAIL:&nbsp;FIELD&nbsp;|&nbsp;CONSTR&nbsp;|&nbsp;<A HREF="#method_detail">METHOD</A></FONT></TD></TR></TABLE><!-- =========== END OF NAVBAR =========== --><HR></BODY></HTML>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -