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

📄 package-summary.html

📁 Medi 这是一个基于Java的媒体文件归档器工具
💻 HTML
📖 第 1 页 / 共 2 页
字号:
<TD>A row of tabular data. </TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD WIDTH="15%"><B><A HREF="DbRowSet.html">DbRowSet</A></B></TD><TD>It contains only a set of rows.</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD WIDTH="15%"><B><A HREF="DbSelector.html">DbSelector</A></B></TD><TD>A class used to select tabular data from an SQL database. </TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD WIDTH="15%"><B><A HREF="DbSequence.html">DbSequence</A></B></TD><TD>Generates unique values for use as keys. </TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD WIDTH="15%"><B><A HREF="DbTable.html">DbTable</A></B></TD><TD>A class representing tabular data. </TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD WIDTH="15%"><B><A HREF="DbTrueExpr.html">DbTrueExpr</A></B></TD><TD>An expression that always evaluates to true. </TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD WIDTH="15%"><B><A HREF="DbUpdater.html">DbUpdater</A></B></TD><TD>A class used to update records from SQL tables. </TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD WIDTH="15%"><B><A HREF="DbValueList.html">DbValueList</A></B></TD><TD>This class represents a set of values to be used in an expression.</TD></TR></TABLE>&nbsp;<P><TABLE BORDER="1" CELLPADDING="3" CELLSPACING="0" WIDTH="100%"><TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor"><TD COLSPAN=2><FONT SIZE="+2"><B>Exception Summary</B></FONT></TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD WIDTH="15%"><B><A HREF="DbException.html">DbException</A></B></TD><TD>An Exception class for this package.</TD></TR></TABLE>&nbsp;<P><A NAME="package_description"><!-- --></A><H2>Package javatools.db Description</H2><P>Database interface classes.
<P>
These classes are designed to provide a nicer, higher level
interface to the database than than provided by raw JDBC.
Part of the design is somewhat modeled on the
<A href="http://www.roguewave.com/products/sourcepro/">
Rogue Wave Source Pro DB</A> C++ class library (formally known
as DBTools.h++). If you are
left wondering "why is it so", reading the online
<A href="http://www.roguewave.com/support/docs/index.cfm">
Rogue-Wave Source Pro DB docs</A> may provide philosophical
answers.
<P>

Of course, everything that you can do with this package can be done
with raw JDBC. For some simple examples, you may feel that jdbc
provides a simpler solution. The real power of this package however is
two-fold. Firstly, it becomes evident when you need to generate SQL on
the fly. This is a typical scenario with a search screen where you can
search on a number of fields. In this case you can find the generation
of the correct SQL to be particularly hazardous. Secondly is in
portability. The framework isolates you from the idiosyncracies of the
SQL database implementation.
<P>
Other areas the framework shines is in general ease of use. While in
some ways the plain SQL of jdbc may appear simpler, keeping track of
the order of dynamic arguments is error prone, and attempting
generation of dynamic SQL is tedious. The DbRow class provides a more
useful way of storing a result row since it persists after each read,
whereas the JDBC ResultSet only can access the current row.
<P>

The framework can provide a portability buffer between different SQL
databases, since it hides the underlying SQL code. At the present
time, there has not been an enormous amount of effort to make this
portabilility work, but some effort has been made to make the package
work with both <A href="http://www.oracle.com">Oracle</A> and <A
href="http://www.postgresql.org/"> Postgresql</A>. Various properties
associated with differing SQL vendors are in the dbvendor.properties
file.

<P>
Each application will generally use a db.properties file
to specify parameters. A typical example would be...
<PRE>
myapp.driver  = oracle.jdbc.driver.OracleDriver
myapp.connect = jdbc:oracle:thin:@dbdev01:1521:devu02
myapp.userId = myloginname
myapp.password = mypassword
myapp.vendor = oracle
</PRE>
<P>
As of the current point in time, no doubt there is much room
for extension and improvement to the framework. But the foundation
seems solid and useful. Much more pleasant than raw JDBC, and
more portable.
<P>
Here is an example of how this package greatly simplifies dynamic
queries... Imagine the situation of a Person object with first and
last names. A query method is required to query on one or the other or
both or neither. With regular JDBC...

<PRE>
public void query(Person p) {
  String sql = "SELECT * FROM PERSON ";
  boolean first = true;
  if (p.getFirstName() != null) {
    sql += "WHERE PERSON.FIRSTNAME = ?";
    first = false;
  }
  if (p.getLastName() != null) {
    if (first) {
      sql += "WHERE ";
    } else {
      sql += " AND ";
    }
    sql += "PERSON.LASTNAME = ?";
    first = false;
  }
  Connection con = ...
  PreparedStatement stmt = con.prepareStatement(sql);
  int count = 1;
  if (p.getFirstName() != null) {
    stmt.setString(count++, p.getFirstName());
  }
  if (p.getLastName() != null) {
    stmt.setString(count++, p.getLastName());
  }
  stmt.execute();
  ...
}
</PRE>
Now compare this to using the framework...
<PRE>
public void query(Person p) {
  DbDatabase db = DbManager.getDatabase("mydb");
  DbTable ptable = db.getTable("PERSON");
  DbSelector select = db.selector();
  selector.addAll(ptable);
  DbExpr expr = db.trueExpr();
  if (p.getFirstName() != null) {
    expr = expr.and(ptable.getColumn("FIRSTNAME").equal(p.getFirstName()));
  }
  if (p.getLastName() != null) {
    expr = expr.and(ptable.getColumn("LASTNAME").equal(p.getLastName()));
  }
  selector.setWhere(expr);
  DbTable result = selector.execute();
  ...
}
</PRE>
Now the framework provides much more readable and maintainable
code. Note the use of trueExpr() to allow dynamically generating
AND expressions.

<P>

If you want to know where to start learning about this package, a good
place to start is <A href="DbManager.html">DbManager</A>. From there
continue to <A href="DbSelector.html">DbSelector</A>, <A
href="DbInserter.html">DbInserter</A>, <A
href="DbDeleter.html">DbDeleter</A> and <A
href="DbUpdater.html">DbUpdater</A>.<P><P><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="#FFFFFF" CLASS="NavBarCell1Rev"> &nbsp;<FONT CLASS="NavBarFont1Rev"><B>Package</B></FONT>&nbsp;</TD>  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <FONT CLASS="NavBarFont1">Class</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/awt/event/package-summary.html"><B>PREV PACKAGE</B></A>&nbsp;&nbsp;<A HREF="../../javatools/db/util/package-summary.html"><B>NEXT PACKAGE</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="package-summary.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></TABLE><!-- =========== END OF NAVBAR =========== --><HR></BODY></HTML>

⌨️ 快捷键说明

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