001    import java.sql.*;
002    
003    /** 
004     * <h2>DBUpdt</h2>
005     *
006     * @author Matthew Hough
007     * @version .01, 6/2/07
008     * @assignment.number A19015
009     * @prgm.usage This is a template for the DBUpdt15 class
010     *
011     */
012    
013    public interface DBUpdt {
014            /**
015             * Accept an ODBC name (that was set up on your computer) along with the
016             * name of the table and the default field name of the key.
017             * <ul>
018             * <li>Store the name of the table in strTable</li>
019             * <li>Store the name of the key field in strKeyField</li>
020             * <li>Create an ODBC Database connection, Return true if successful, false
021             * if not</li>
022             * </ul>
023             */
024            public boolean open(String strConn, String strTable, String strKeyField)
025                            throws Exception;
026    
027            /**
028             * Execute an SQL query on the database.
029             */
030            public ResultSet query(String strSQL) throws Exception;
031    
032            /**
033             * Close the database connection.
034             */
035            public void close() throws Exception;
036    
037            /**
038             * Returns the number of fields in this recordset.
039             * 
040             * @see <br>
041             *      <a
042             *      href="http://java.sun.com/j2se/1.5.0/docs/api/java/sql/ResultSetMetaData.html">Java
043             *      java.sql.ResultSetMetaData class</a>
044             */
045            public int getFieldCount() throws Exception;
046    
047            /**
048             * Returns the name of the field at position intFldNum.
049             * 
050             * @see <br>
051             *      <a
052             *      href="http://java.sun.com/j2se/1.5.0/docs/api/java/sql/ResultSetMetaData.html">Java
053             *      java.sql.ResultSetMetaData class</a>
054             */
055            public String getFieldName(int intFieldNum) throws Exception;
056    
057            /**
058             * Returns the contents of the field using a position number <br>
059             * intFldNum, intFldNum must be >= 1.
060             * 
061             * @see <br>
062             *      <a
063             *      href="http://java.sun.com/j2se/1.5.0/docs/api/java/sql/ResultSet.html">Java
064             *      java.sql.ResultSet class</a>
065             */
066            public String getField(int intFieldNum) throws Exception;
067    
068            /**
069             * Returns the contents of the field specified by strFldName.
070             * 
071             * @see <br>
072             *      <a
073             *      href="http://java.sun.com/j2se/1.5.0/docs/api/java/sql/ResultSet.html">Java
074             *      java.sql.ResultSet class</a>
075             */
076            public ResultSet getField(String strFieldName) throws Exception;
077    
078            /**
079             * Check to see if there are any more records to be processed in the
080             * recordset. This should only take one line of code.
081             * 
082             * @see <br>
083             *      <a
084             *      href="http://java.sun.com/j2se/1.5.0/docs/api/java/sql/ResultSetMetaData.html">Java
085             *      java.sql.ResultSetMetaData class</a>
086             */
087            public boolean moreRecords() throws Exception;
088    
089            /**
090             * Look for strKey in the field called for by the default key field
091             * (strKeyField); If the record is not found, add a record to the database;
092             * If it is found, just ignore the request.
093             */
094            public void add(String strKey) throws Exception;
095    
096            /**
097             * Using strKey, look up the record, and once found, update strFieldName
098             * field with strContent. <br>
099             * Note: <br>
100             * You should only update one field at a time. If you have multiple fields
101             * to update in a record, you need to call this function multiple times.
102             */
103            public void setField(String strContent, String strFieldName, String strKey)
104                            throws Exception;
105    
106            /**
107             * Send a string to the console (System.out.print)- this should be used
108             * throughtout your program to indicate progress and display variable
109             * contents - see DemoMain11 for code.
110             */
111            public void status(String strVar);
112    } // end of interface
113