CallableStatement.java
上传用户:psq1974
上传日期:2007-01-06
资源大小:1195k
文件大小:10k
源码类别:

mpeg/mp3

开发平台:

C/C++

  1. package postgresql;
  2. import java.sql.*;
  3. import java.math.*;
  4. /**
  5.  * CallableStatement is used to execute SQL stored procedures.
  6.  *
  7.  * <p>JDBC provides a stored procedure SQL escape that allows stored
  8.  * procedures to be called in a standard way for all RDBMS's. This escape
  9.  * syntax has one form that includes a result parameter and one that does
  10.  * not. If used, the result parameter must be registered as an OUT
  11.  * parameter. The other parameters may be used for input, output or both.
  12.  * Parameters are refered to sequentially, by number. The first parameter
  13.  * is 1.
  14.  *
  15.  * {?= call <procedure-name>[<arg1>,<arg2>, ...]}                 
  16.  * {call <procedure-name>[<arg1>,<arg2>, ...]}       
  17.  *
  18.  *
  19.  * <p>IN parameter values are set using the set methods inherited from
  20.  * PreparedStatement. The type of all OUT parameters must be registered
  21.  * prior to executing the stored procedure; their values are retrieved
  22.  * after execution via the get methods provided here.
  23.  *
  24.  * <p>A Callable statement may return a ResultSet or multiple ResultSets.
  25.  * Multiple ResultSets are handled using operations inherited from
  26.  * Statement.
  27.  *
  28.  * <p>For maximum portability, a call's ResultSets and update counts should 
  29.  * be processed prior to getting the values of output parameters.        
  30.  *
  31.  * @see Connection#prepareCall
  32.  * @see ResultSet
  33.  */
  34. public class CallableStatement extends PreparedStatement implements java.sql.CallableStatement
  35. {
  36.   /**
  37.    * @exception SQLException on failure
  38.    */
  39.   CallableStatement(Connection c,String q) throws SQLException
  40.   {
  41.     super(c,q);
  42.   }
  43.   
  44.   /**
  45.    * Before executing a stored procedure call you must explicitly
  46.    * call registerOutParameter to register the java.sql.Type of each
  47.    * out parameter.
  48.    *
  49.    * <p>Note: When reading the value of an out parameter, you must use
  50.    * the getXXX method whose Java type XXX corresponds to the
  51.    * parameter's registered SQL type.
  52.    *
  53.    * @param parameterIndex the first parameter is 1, the second is 2,...
  54.    * @param sqlType SQL type code defined by java.sql.Types; for
  55.    * parameters of type Numeric or Decimal use the version of
  56.    * registerOutParameter that accepts a scale value
  57.    * @exception SQLException if a database-access error occurs.
  58.    */
  59.   public void registerOutParameter(int parameterIndex, int sqlType) throws SQLException {
  60.   }
  61.   
  62.   /**
  63.    * You must also specify the scale for numeric/decimal types:
  64.    *
  65.    * <p>Note: When reading the value of an out parameter, you must use
  66.    * the getXXX method whose Java type XXX corresponds to the
  67.    * parameter's registered SQL type.
  68.    *
  69.    * @param parameterIndex the first parameter is 1, the second is 2,...
  70.    * @param sqlType use either java.sql.Type.NUMERIC or java.sql.Type.DECIMAL
  71.    * @param scale a value greater than or equal to zero representing the
  72.    * desired number of digits to the right of the decimal point
  73.    * @exception SQLException if a database-access error occurs.
  74.    */
  75.   public void registerOutParameter(int parameterIndex, int sqlType,
  76.    int scale) throws SQLException
  77.   {
  78.   }
  79.   
  80.   // Old api?
  81.   //public boolean isNull(int parameterIndex) throws SQLException {
  82.   //return true;
  83.   //}
  84.   
  85.   /**
  86.    * An OUT parameter may have the value of SQL NULL; wasNull
  87.    * reports whether the last value read has this special value.
  88.    *
  89.    * <p>Note: You must first call getXXX on a parameter to read its
  90.    * value and then call wasNull() to see if the value was SQL NULL.
  91.    * @return true if the last parameter read was SQL NULL
  92.    * @exception SQLException if a database-access error occurs.
  93.    */
  94.   public boolean wasNull() throws SQLException {
  95.     // check to see if the last access threw an exception
  96.     return false; // fake it for now
  97.   }
  98.   
  99.   // Old api?
  100.   //public String getChar(int parameterIndex) throws SQLException {
  101.   //return null;
  102.   //}
  103.   
  104.   /**
  105.    * Get the value of a CHAR, VARCHAR, or LONGVARCHAR parameter as a
  106.    * Java String.
  107.    *
  108.    * @param parameterIndex the first parameter is 1, the second is 2,...
  109.    * @return the parameter value; if the value is SQL NULL, the result is null
  110.    * @exception SQLException if a database-access error occurs.
  111.    */
  112.   public String getString(int parameterIndex) throws SQLException {
  113.     return null;
  114.   }
  115.   //public String getVarChar(int parameterIndex) throws SQLException {
  116.   //   return null;
  117.   //}
  118.   
  119.   //public String getLongVarChar(int parameterIndex) throws SQLException {
  120.   //return null;
  121.   //}
  122.   
  123.   /**
  124.    * Get the value of a BIT parameter as a Java boolean.
  125.    *
  126.    * @param parameterIndex the first parameter is 1, the second is 2,...
  127.    * @return the parameter value; if the value is SQL NULL, the result is false
  128.    * @exception SQLException if a database-access error occurs.
  129.    */
  130.   public boolean getBoolean(int parameterIndex) throws SQLException {
  131.     return false;
  132.   }
  133.   
  134.   /**
  135.    * Get the value of a TINYINT parameter as a Java byte.
  136.    *
  137.    * @param parameterIndex the first parameter is 1, the second is 2,...
  138.    * @return the parameter value; if the value is SQL NULL, the result is 0
  139.    * @exception SQLException if a database-access error occurs.
  140.    */
  141.   public byte getByte(int parameterIndex) throws SQLException {
  142.     return 0;
  143.   }
  144.   
  145.   /**
  146.    * Get the value of a SMALLINT parameter as a Java short.
  147.    *
  148.    * @param parameterIndex the first parameter is 1, the second is 2,...
  149.    * @return the parameter value; if the value is SQL NULL, the result is 0
  150.    * @exception SQLException if a database-access error occurs.
  151.    */
  152.   public short getShort(int parameterIndex) throws SQLException {
  153.     return 0;
  154.   }
  155.   
  156.   /**
  157.    * Get the value of an INTEGER parameter as a Java int.
  158.    *
  159.    * @param parameterIndex the first parameter is 1, the second is 2,...
  160.    * @return the parameter value; if the value is SQL NULL, the result is 0
  161.    * @exception SQLException if a database-access error occurs.
  162.    */
  163. public int getInt(int parameterIndex) throws SQLException {
  164.     return 0;
  165.   }
  166.   
  167.   /**
  168.    * Get the value of a BIGINT parameter as a Java long.
  169.    *
  170.    * @param parameterIndex the first parameter is 1, the second is 2,...
  171.    * @return the parameter value; if the value is SQL NULL, the result is 0
  172.    * @exception SQLException if a database-access error occurs.
  173.    */
  174.   public long getLong(int parameterIndex) throws SQLException {
  175.     return 0;
  176.   }
  177.   
  178.   /**
  179.    * Get the value of a FLOAT parameter as a Java float.
  180.    *
  181.    * @param parameterIndex the first parameter is 1, the second is 2,...
  182.    * @return the parameter value; if the value is SQL NULL, the result is 0
  183.    * @exception SQLException if a database-access error occurs.
  184.    */
  185.   public float getFloat(int parameterIndex) throws SQLException {
  186.     return (float) 0.0;
  187.   }
  188.   
  189.   /**
  190.    * Get the value of a DOUBLE parameter as a Java double.
  191.    *
  192.    * @param parameterIndex the first parameter is 1, the second is 2,...
  193.    * @return the parameter value; if the value is SQL NULL, the result is 0
  194.    * @exception SQLException if a database-access error occurs.
  195.    */
  196.   public double getDouble(int parameterIndex) throws SQLException {
  197.     return 0.0;
  198.   }
  199.   
  200.   /**
  201.    * Get the value of a NUMERIC parameter as a java.math.BigDecimal
  202.    * object.
  203.    *
  204.    * @param parameterIndex the first parameter is 1, the second is 2,...
  205.    * @param scale a value greater than or equal to zero representing the
  206.    * desired number of digits to the right of the decimal point
  207.    * @return the parameter value; if the value is SQL NULL, the result is null
  208.    * @exception SQLException if a database-access error occurs.
  209.    */
  210.   public BigDecimal getBigDecimal(int parameterIndex, int scale)
  211.        throws SQLException {
  212.  return null;
  213.   }
  214.   
  215.   /**
  216.    * Get the value of a SQL BINARY or VARBINARY parameter as a Java
  217.    * byte[]
  218.    *
  219.    * @param parameterIndex the first parameter is 1, the second is 2,...
  220.    * @return the parameter value; if the value is SQL NULL, the result is null
  221.    * @exception SQLException if a database-access error occurs.
  222.    */
  223.   public byte[] getBytes(int parameterIndex) throws SQLException {
  224.     return null;
  225.   }
  226.   
  227.   // New API (JPM) (getLongVarBinary)
  228.   //public byte[] getBinaryStream(int parameterIndex) throws SQLException {
  229.   //return null;
  230.   //}
  231.   
  232.   /**
  233.    * Get the value of a SQL DATE parameter as a java.sql.Date object
  234.    *
  235.    * @param parameterIndex the first parameter is 1, the second is 2,...
  236.    * @return the parameter value; if the value is SQL NULL, the result is null
  237.    * @exception SQLException if a database-access error occurs.
  238.    */
  239.   public java.sql.Date getDate(int parameterIndex) throws SQLException {
  240.     return null;
  241.   }
  242.   
  243.   /**
  244.    * Get the value of a SQL TIME parameter as a java.sql.Time object.
  245.    *
  246.    * @param parameterIndex the first parameter is 1, the second is 2,...
  247.    * @return the parameter value; if the value is SQL NULL, the result is null
  248.    * @exception SQLException if a database-access error occurs.
  249.    */
  250.   public java.sql.Time getTime(int parameterIndex) throws SQLException {
  251.     return null;
  252.   }
  253.   
  254.   /**
  255.    * Get the value of a SQL TIMESTAMP parameter as a java.sql.Timestamp object.
  256.    *
  257.    * @param parameterIndex the first parameter is 1, the second is 2,...
  258.    * @return the parameter value; if the value is SQL NULL, the result is null
  259.    * @exception SQLException if a database-access error occurs.
  260.    */
  261.   public java.sql.Timestamp getTimestamp(int parameterIndex)
  262.        throws SQLException {
  263.  return null;
  264.   }
  265.   
  266.   //----------------------------------------------------------------------
  267.   // Advanced features:
  268.   
  269.   // You can obtain a ParameterMetaData object to get information 
  270.   // about the parameters to this CallableStatement.
  271.   //public DatabaseMetaData getMetaData() {
  272.   //return null;
  273.   //}
  274.   
  275.   // getObject returns a Java object for the parameter.
  276.   // See the JDBC spec's "Dynamic Programming" chapter for details.
  277.   /**
  278.    * Get the value of a parameter as a Java object.
  279.    *
  280.    * <p>This method returns a Java object whose type coresponds to the
  281.    * SQL type that was registered for this parameter using
  282.    * registerOutParameter.
  283.    *
  284.    * <P>Note that this method may be used to read datatabase-specific,
  285.    * abstract data types. This is done by specifying a targetSqlType
  286.    * of java.sql.types.OTHER, which allows the driver to return a
  287.    * database-specific Java type.
  288.    *
  289.    * <p>See the JDBC spec's "Dynamic Programming" chapter for details.
  290.    *
  291.    * @param parameterIndex the first parameter is 1, the second is 2,...
  292.    * @return A java.lang.Object holding the OUT parameter value.
  293.    * @exception SQLException if a database-access error occurs.
  294.    */
  295.   public Object getObject(int parameterIndex)
  296.        throws SQLException {
  297.  return null;
  298.   }
  299. }