java.sql

Interface PreparedStatement

All Superinterfaces:
Statement
Known Subinterfaces:
CallableStatement
Known Implementing Classes:
DelegatingCallableStatement, DelegatingPreparedStatement, PoolablePreparedStatement

public interface PreparedStatement
extends Statement

An object that represents a precompiled SQL statement.

A SQL statement is precompiled and stored in a PreparedStatement object. This object can then be used to efficiently execute this statement multiple times.

Note: The setter methods (setShort, setString, and so on) for setting IN parameter values must specify types that are compatible with the defined SQL type of the input parameter. For instance, if the IN parameter has SQL type INTEGER, then the method setInt should be used.

If arbitrary parameter type conversions are required, the method setObject should be used with a target SQL type.

In the following example of setting a parameter, con represents an active connection:

   PreparedStatement pstmt = con.prepareStatement("UPDATE EMPLOYEES
                                     SET SALARY = ? WHERE ID = ?");
   pstmt.setBigDecimal(1, 153833.00)
   pstmt.setInt(2, 110592)
 
See Also:
Connection.prepareStatement, ResultSet

Fields inherited from interface java.sql.Statement

CLOSE_ALL_RESULTS, CLOSE_CURRENT_RESULT, EXECUTE_FAILED, KEEP_CURRENT_RESULT, NO_GENERATED_KEYS, RETURN_GENERATED_KEYS, SUCCESS_NO_INFO

Method Summary

void
addBatch()
Adds a set of parameters to this PreparedStatement object's batch of commands.
void
clearParameters()
Clears the current parameter values immediately.
boolean
execute()
Executes the SQL statement in this PreparedStatement object, which may be any kind of SQL statement.
ResultSet
executeQuery()
Executes the SQL query in this PreparedStatement object and returns the ResultSet object generated by the query.
int
executeUpdate()
Executes the SQL statement in this PreparedStatement object, which must be an SQL INSERT, UPDATE or DELETE statement; or an SQL statement that returns nothing, such as a DDL statement.
ResultSetMetaData
getMetaData()
Retrieves a ResultSetMetaData object that contains information about the columns of the ResultSet object that will be returned when this PreparedStatement object is executed.
ParameterMetaData
getParameterMetaData()
Retrieves the number, types and properties of this PreparedStatement object's parameters.
void
setArray(int i, Array x)
Sets the designated parameter to the given Array object.
void
setAsciiStream(int parameterIndex, InputStream x, int length)
Sets the designated parameter to the given input stream, which will have the specified number of bytes.
void
setBigDecimal(int parameterIndex, BigDecimal x)
Sets the designated parameter to the given java.math.BigDecimal value.
void
setBinaryStream(int parameterIndex, InputStream x, int length)
Sets the designated parameter to the given input stream, which will have the specified number of bytes.
void
setBlob(int i, Blob x)
Sets the designated parameter to the given Blob object.
void
setBoolean(int parameterIndex, boolean x)
Sets the designated parameter to the given Java boolean value.
void
setByte(int parameterIndex, byte x)
Sets the designated parameter to the given Java byte value.
void
setBytes(int parameterIndex, x[] )
Sets the designated parameter to the given Java array of bytes.
void
setCharacterStream(int parameterIndex, Reader reader, int length)
Sets the designated parameter to the given Reader object, which is the given number of characters long.
void
setClob(int i, Clob x)
Sets the designated parameter to the given Clob object.
void
setDate(int parameterIndex, Date x)
Sets the designated parameter to the given java.sql.Date value.
void
setDate(int parameterIndex, Date x, Calendar cal)
Sets the designated parameter to the given java.sql.Date value, using the given Calendar object.
void
setDouble(int parameterIndex, double x)
Sets the designated parameter to the given Java double value.
void
setFloat(int parameterIndex, float x)
Sets the designated parameter to the given Java float value.
void
setInt(int parameterIndex, int x)
Sets the designated parameter to the given Java int value.
void
setLong(int parameterIndex, long x)
Sets the designated parameter to the given Java long value.
void
setNull(int parameterIndex, int sqlType)
Sets the designated parameter to SQL NULL.
void
setNull(int paramIndex, int sqlType, String typeName)
Sets the designated parameter to SQL NULL.
void
setObject(int parameterIndex, Object x)
Sets the value of the designated parameter using the given object.
void
setObject(int parameterIndex, Object x, int targetSqlType)
Sets the value of the designated parameter with the given object.
void
setObject(int parameterIndex, Object x, int targetSqlType, int scale)
Sets the value of the designated parameter with the given object.
void
setRef(int i, Ref x)
Sets the designated parameter to the given REF(<structured-type>) value.
void
setShort(int parameterIndex, short x)
Sets the designated parameter to the given Java short value.
void
setString(int parameterIndex, String x)
Sets the designated parameter to the given Java String value.
void
setTime(int parameterIndex, Time x)
Sets the designated parameter to the given java.sql.Time value.
void
setTime(int parameterIndex, Time x, Calendar cal)
Sets the designated parameter to the given java.sql.Time value, using the given Calendar object.
void
setTimestamp(int parameterIndex, Timestamp x)
Sets the designated parameter to the given java.sql.Timestamp value.
void
setTimestamp(int parameterIndex, Timestamp x, Calendar cal)
Sets the designated parameter to the given java.sql.Timestamp value, using the given Calendar object.
void
setURL(int parameterIndex, URL x)
Sets the designated parameter to the given java.net.URL value.
@Deprecated
void setUnicodeStream(int parameterIndex, InputStream x, int length)
Deprecated.

Methods inherited from interface java.sql.Statement

addBatch, cancel, clearBatch, clearWarnings, close, execute, execute, execute, execute, executeBatch, executeQuery, executeUpdate, executeUpdate, executeUpdate, executeUpdate, getConnection, getFetchDirection, getFetchSize, getGeneratedKeys, getMaxFieldSize, getMaxRows, getMoreResults, getMoreResults, getQueryTimeout, getResultSet, getResultSetConcurrency, getResultSetHoldability, getResultSetType, getUpdateCount, getWarnings, setCursorName, setEscapeProcessing, setFetchDirection, setFetchSize, setMaxFieldSize, setMaxRows, setQueryTimeout

Method Details

addBatch

public void addBatch()
            throws SQLException
Adds a set of parameters to this PreparedStatement object's batch of commands.
Throws:
SQLException - if a database access error occurs
Since:
1.2
Usages and Demos :

View More Examples of addBatch()
   1: 
   2: import java.sql.PreparedStatement;
   3: import java.sql.Connection;
   4:         ...
   5: 
   6:     public PreparedStatement execute(Connection conn) throws SQLException {
   7:         return getSqlAdapter().getDeletePreparedStatement(conn);
   8:         ...
   9: 
  10:     public void addToBatch(PreparedStatement stmt) throws SQLException {
  11:         getSqlAdapter().addToDeleteBatch(stmt);
  12:         ...
  13:         stmt.addBatch();

View Full Code Here
   1: 
   2: import java.sql.PreparedStatement;
   3: import java.sql.Connection;
   4:         ...
   5: 
   6:     public PreparedStatement execute(Connection conn) throws SQLException {
   7:         return getSqlAdapter().getInsertPreparedStatement(conn);
   8:         ...
   9: 
  10:     public void addToBatch(PreparedStatement stmt) throws SQLException {
  11:         getSqlAdapter().addToInsertBatch(stmt);
  12:         ...
  13:         stmt.addBatch();

View Full Code Here
   1:     private Connection con;
   2:     private PreparedStatement pstmt;
   3: 
   4:         ...
   5:             pstmt.setString(3, p.getProperty(temp));
   6:             pstmt.addBatch();
   7:         
   8:         }
   9:         pstmt.execute();

View Full Code Here
   1: 
   2: import java.sql.PreparedStatement;
   3: import java.sql.SQLException;
   4:         ...
   5:         log.trace("Adding to batch");
   6:         PreparedStatement batchUpdate = getStatement();
   7:         ...
   8:         batchUpdate.addBatch();
   9:         batchSize++;
  10:         ...
  11:     
  12:     protected void doExecuteBatch(PreparedStatement ps) throws SQLException, HibernateException {

View Full Code Here
   1: 
   2: import java.sql.PreparedStatement;
   3: import java.sql.SQLException;
   4:         ...
   5:         log.trace("Adding to batch");
   6:         PreparedStatement batchUpdate = getStatement();
   7:         ...
   8:         batchUpdate.addBatch();
   9:         batchSize++;
  10:         ...
  11:     
  12:     protected void doExecuteBatch(PreparedStatement ps) throws SQLException, HibernateException {

View Full Code Here

clearParameters

public void clearParameters()
            throws SQLException
Clears the current parameter values immediately.

In general, parameter values remain in force for repeated use of a statement. Setting a parameter value automatically clears its previous value. However, in some cases it is useful to immediately release the resources used by the current parameter values; this can be done by calling the method clearParameters.

Throws:
SQLException - if a database access error occurs
Usages and Demos :

View More Examples of clearParameters()
   1:         {
   2:             PreparedStatement pstmt=conn.prepareStatement("select userName from UserInfo where userName=? and password=?");
   3:         ...
   4:             pstmt.clearParameters();
   5:             pstmt.setString(1,this.userName);
   6:             pstmt.setString(2,this.password);
   7:             ResultSet rset=pstmt.executeQuery();

View Full Code Here
   1:         {
   2:             PreparedStatement pstmt=conn.prepareStatement("select adminName from adminInfo where adminName=? and password=?");
   3:         ...
   4:             pstmt.clearParameters();
   5:             pstmt.setString(1,this.adminName);
   6:             pstmt.setString(2,this.password);
   7:             ResultSet rset=pstmt.executeQuery();

View Full Code Here
   1:             Connection con = ds.getConnection("borg", "");
   2:             PreparedStatement acct, cust;
   3: 
   4:         ...
   5: 
   6:                 acct.clearParameters();
   7:         ...
   8:                 cust.clearParameters();
   9:                 acct_id = rs.getLong(1);

View Full Code Here
   1: 
   2:         PreparedStatement createBeanProductStatement =
   3:             getConnection().prepareStatement(
   4:         ...
   5: 
   6:         createBeanProductStatement.clearParameters();
   7:         createBeanProductStatement.setString(1, "000");
   8:         createBeanProductStatement.setString(2, "Sumatra");
   9:         createBeanProductStatement.setInt(3, 725);

View Full Code Here
   1: 
   2:         PreparedStatement insertStatement =
   3:             connection.prepareStatement(
   4:         ...
   5:         Connection connection = getConnection();
   6:         PreparedStatement findExpensiveCoffeeStatement =
   7:             connection.prepareStatement(
   8:         ...
   9:         Connection connection = getConnection();
  10:         PreparedStatement findAllCoffeeStatement =
  11:             connection.prepareStatement("select * from catalog.beans");
  12:         ...
  13: 
  14:         insertStatement.clearParameters();

View Full Code Here

execute

public boolean execute()
            throws SQLException
Executes the SQL statement in this PreparedStatement object, which may be any kind of SQL statement. Some prepared statements return multiple results; the execute method handles these complex statements as well as the simpler form of statements handled by the methods executeQuery and executeUpdate.

The execute method returns a boolean to indicate the form of the first result. You must call either the method getResultSet or getUpdateCount to retrieve the result; you must call getMoreResults to move to any subsequent result(s).

Returns:
true if the first result is a ResultSet object; false if the first result is an update count or there is no result
Throws:
SQLException - if a database access error occurs or an argument is supplied to this method
See Also:
Statement.execute, Statement.getResultSet(), Statement.getUpdateCount(), Statement.getMoreResults
Usages and Demos :

View More Examples of execute()
   1: 
   2:           PreparedStatement ps;
   3:           ps = con.prepareStatement ("insert into employee(name,photo) "+
   4:         ...
   5:               ps.setBlob (2, blob);
   6:               ps.execute();
   7:           }
   8:           catch (Exception ex)
   9:           {

View Full Code Here
   1:     private Connection con;
   2:     private PreparedStatement pstmt;
   3: 
   4:         ...
   5:         }
   6:         pstmt.execute();
   7:         con.commit();
   8:         } catch(Exception e) {
   9:             System.out.println("Failure to process vote"+e);

View Full Code Here
   1: import java.sql.Connection;
   2: import java.sql.PreparedStatement;
   3: import java.sql.SQLException;
   4:         ...
   5:   public static int insert(Connection db, String name, boolean enabled) throws SQLException {
   6:     PreparedStatement pst = db.prepareStatement(
   7:         "INSERT INTO groups " +
   8:         ...
   9:     pst.setBoolean(2, enabled);
  10:     pst.execute();
  11:     pst.close();

View Full Code Here
   1: import java.sql.SQLException;
   2: import java.sql.PreparedStatement;
   3: 
   4:         ...
   5:   public static int insert(Connection db, int groupId, String description, boolean enabled) throws SQLException {
   6:     PreparedStatement pst = db.prepareStatement(
   7:         "INSERT INTO departments " +
   8:         ...
   9:     pst.setBoolean(3, enabled);
  10:     pst.execute();
  11:     pst.close();

View Full Code Here
   1: import java.sql.Connection;
   2: import java.sql.PreparedStatement;
   3: import java.sql.ResultSet;
   4:         ...
   5:         List<String> hosts = new ArrayList<String>();
   6:         PreparedStatement ps = connection.prepareStatement("SELECT host "
   7:                 + "FROM events " + "GROUP BY host;");
   8:         ...
   9:                 ps.setInt(2, ip);
  10:                 ps.execute();
  11:             } finally {

View Full Code Here

executeQuery

public ResultSet executeQuery()
            throws SQLException
Executes the SQL query in this PreparedStatement object and returns the ResultSet object generated by the query.
Returns:
a ResultSet object that contains the data produced by the query; never null
Throws:
SQLException - if a database access error occurs or the SQL statement does not return a ResultSet object
Usages and Demos :

View More Examples of executeQuery()
   1:         {
   2:             PreparedStatement pstmt=conn.prepareStatement("select userName from UserInfo where userName=? and password=?");
   3:             pstmt.clearParameters();
   4:         ...
   5:             pstmt.setString(2,this.password);
   6:             ResultSet rset=pstmt.executeQuery();
   7:             if(rset.next())
   8:             {
   9:             

View Full Code Here
   1:         {
   2:             PreparedStatement pstmt=conn.prepareStatement("select adminName from adminInfo where adminName=? and password=?");
   3:             pstmt.clearParameters();
   4:         ...
   5:             pstmt.setString(2,this.password);
   6:             ResultSet rset=pstmt.executeQuery();
   7:             if(rset.next())
   8:             {
   9:             

View Full Code Here
   1:       String sql = "SELECT * FROM Personen WHERE nachname LIKE ?";
   2:       PreparedStatement ps = c.prepareStatement(sql);
   3:       ps.setString(1, par);
   4:         ...
   5:       ResultSet r = ps.executeQuery();
   6:       while(r.next())
   7:         System.out.println(r.getString("vorname")+ ", "+ r.getString("nachname"));
   8:     }

View Full Code Here
   1: import java.sql.Connection;
   2: import java.sql.PreparedStatement;
   3: import java.sql.SQLException;
   4:         ...
   5:    {
   6:       PreparedStatement ps = null;
   7:       
   8:         ...
   9:          ps = connection.prepareStatement("SELECT " + sequenceName + ".nextval FROM dual");
  10:          ResultSet rs = ps.executeQuery();
  11:          

View Full Code Here
   1:     Connection cn = Examples.getConnection();
   2:     PreparedStatement ps =
   3:       cn.prepareStatement("SELECT q.symbol as \"Symbol\", " +
   4:         ...
   5:     ps.setInt( 1, customerId );
   6:     ResultSet rs = ps.executeQuery();
   7:     PrintWriter pw = new PrintWriter(out);
   8:     XMLForResultSet.print(rs,"Quotes","Quote", pw);
   9:     pw.close(); rs.close(); ps.close(); cn.close();

View Full Code Here

executeUpdate

public int executeUpdate()
            throws SQLException
Executes the SQL statement in this PreparedStatement object, which must be an SQL INSERT, UPDATE or DELETE statement; or an SQL statement that returns nothing, such as a DDL statement.
Returns:
either (1) the row count for INSERT, UPDATE, or DELETE statements or (2) 0 for SQL statements that return nothing
Throws:
SQLException - if a database access error occurs or the SQL statement returns a ResultSet object
Usages and Demos :

View More Examples of executeUpdate()
   1:             Connection con = DriverManager.getConnection(url, "kgh", "");
   2:             PreparedStatement stmt = con.prepareStatement(
   3:                     "UPDATE Table1 SET a = ? WHERE key = ?");
   4:         ...
   5:             stmt.setString(2, "count");
   6:             stmt.executeUpdate();
   7:             System.out.println("Updated \"count\" row OK.");
   8:         ...
   9:             stmt.setString(2, "mirror");
  10:             stmt.executeUpdate();
  11:             System.out.println("Updated \"mirror\" row OK.");

View Full Code Here
   1:       String sql = "insert into Notifications ( message, sequence_number, " + " source, timestamp, type, user_data ) values ( ?,?,?,?,?,? )";
   2:       PreparedStatement ps = con.prepareStatement( sql );
   3: 
   4:         ...
   5: 
   6:       ps.executeUpdate();
   7:       con.commit();
   8:     }
   9:     catch( Exception e )

View Full Code Here
   1:                   Connection conn = null;
   2:                   PreparedStatement pstmt = null;
   3:                   try {
   4:                       System.out.println("--Delete_Records_ begin--");
   5:                       conn = VeryBasicConnectionManager.getConnection(dbVendor);

View Full Code Here
   1: public class StoreData {
   2:   private PreparedStatement pstmt;
   3: 
   4:         ...
   5:     pstmt.setString(9, student.getZip());
   6:     pstmt.executeUpdate();
   7:   }
   8: }

View Full Code Here
   1:     public void setLockMode(Connection con,int sec) {
   2:         PreparedStatement statement;
   3:         try {
   4:         ...
   5:             }
   6:             statement.executeUpdate();
   7:             statement.close();
   8:         } catch (Exception e) {
   9:             log.error("failed to set lock mode "+e);

View Full Code Here

getMetaData

public ResultSetMetaData getMetaData()
            throws SQLException
Retrieves a ResultSetMetaData object that contains information about the columns of the ResultSet object that will be returned when this PreparedStatement object is executed.

Because a PreparedStatement object is precompiled, it is possible to know about the ResultSet object that it will return without having to execute it. Consequently, it is possible to invoke the method getMetaData on a PreparedStatement object rather than waiting to execute it and then invoking the ResultSet.getMetaData method on the ResultSet object that is returned.

NOTE: Using this method may be expensive for some drivers due to the lack of underlying DBMS support.

Returns:
the description of a ResultSet object's columns or null if the driver cannot return a ResultSetMetaData object
Throws:
SQLException - if a database access error occurs
Since:
1.2
Usages and Demos :

View More Examples of getMetaData()
   1: import java.sql.Date;
   2: import java.sql.PreparedStatement;
   3: import java.sql.Ref;
   4:         ...
   5: 
   6: abstract class C3P0PreparedStatement extends C3P0Statement implements PreparedStatement
   7: {
   8:         ...
   9:     final PreparedStatement inner;
  10: 
  11:         ...
  12:     {
  13:         return inner.getMetaData();

View Full Code Here
   1: import java.sql.Date;
   2: import java.sql.PreparedStatement;
   3: import java.sql.Ref;
   4:         ...
   5: 
   6: abstract class C3P0PreparedStatement extends C3P0Statement implements PreparedStatement
   7: {
   8:         ...
   9:     final PreparedStatement inner;
  10: 
  11:         ...
  12:     {
  13:         return inner.getMetaData();

View Full Code Here
   1: public class PreparedStatementAdapter extends StatementAdapter
   2:         implements PreparedStatement
   3:  {
   4:         ...
   5: 
   6:     protected PreparedStatement pstmt;
   7: 
   8:         ...
   9:     public PreparedStatementAdapter(PreparedStatement pstmt) {
  10:         super(pstmt);
  11:         ...
  12:     public ResultSetMetaData getMetaData() throws SQLException {
  13:         return pstmt.getMetaData();

View Full Code Here
   1: import java.sql.ParameterMetaData;
   2: import java.sql.PreparedStatement;
   3: import java.sql.Ref;
   4:         ...
   5: 
   6: public abstract class FilterPreparedStatement implements PreparedStatement
   7: {
   8:         ...
   9:     protected PreparedStatement inner;
  10:     
  11:         ...
  12:     public ResultSetMetaData getMetaData() throws SQLException
  13:     { return inner.getMetaData(); }

View Full Code Here
   1: import java.sql.ParameterMetaData;
   2: import java.sql.PreparedStatement;
   3: import java.sql.Ref;
   4:         ...
   5: 
   6: public abstract class SynchronizedFilterPreparedStatement implements PreparedStatement
   7: {
   8:         ...
   9:     protected PreparedStatement inner;
  10:     
  11:         ...
  12:     public synchronized ResultSetMetaData getMetaData() throws SQLException
  13:     { return inner.getMetaData(); }

View Full Code Here

getParameterMetaData

public ParameterMetaData getParameterMetaData()
            throws SQLException
Retrieves the number, types and properties of this PreparedStatement object's parameters.
Returns:
a ParameterMetaData object that contains information about the number, types and properties of this PreparedStatement object's parameters
Throws:
SQLException - if a database access error occurs
Since:
1.4
Usages and Demos :

View More Examples of getParameterMetaData()
   1: Connection conn = null;
   2: PreparedStatement pstmt = null;
   3: ParameterMetaData paramMetaData = null;
   4:         ...
   5: pstmt = conn.prepareStatement(query);
   6: paramMetaData = pstmt.getParameterMetaData();
   7: if (paramMetaData == null) {
   8: System.out.println("db vendor does NOT support ParameterMetaData");
   9: }

View Full Code Here
   1: public class PreparedStatementAdapter extends StatementAdapter
   2:         implements PreparedStatement
   3:  {
   4:         ...
   5: 
   6:     protected PreparedStatement pstmt;
   7: 
   8:         ...
   9:     public PreparedStatementAdapter(PreparedStatement pstmt) {
  10:         super(pstmt);
  11:         ...
  12:     public ParameterMetaData getParameterMetaData()throws SQLException {
  13:         return pstmt.getParameterMetaData();

View Full Code Here
   1: import java.sql.ParameterMetaData;
   2: import java.sql.PreparedStatement;
   3: import java.sql.Ref;
   4:         ...
   5: 
   6: public abstract class FilterPreparedStatement implements PreparedStatement
   7: {
   8:         ...
   9:     protected PreparedStatement inner;
  10:     
  11:         ...
  12:     public ParameterMetaData getParameterMetaData() throws SQLException
  13:     { return inner.getParameterMetaData(); }

View Full Code Here
   1: import java.sql.ParameterMetaData;
   2: import java.sql.PreparedStatement;
   3: import java.sql.Ref;
   4:         ...
   5: 
   6: public abstract class SynchronizedFilterPreparedStatement implements PreparedStatement
   7: {
   8:         ...
   9:     protected PreparedStatement inner;
  10:     
  11:         ...
  12:     public synchronized ParameterMetaData getParameterMetaData() throws SQLException
  13:     { return inner.getParameterMetaData(); }

View Full Code Here
   1: import java.sql.ParameterMetaData;
   2: import java.sql.PreparedStatement;
   3: import java.sql.Ref;
   4:         ...
   5:     
   6:     private PreparedStatement stmt;
   7:     private ResultSet rs;
   8:         ...
   9:             }
  10:             int count = stmt.getParameterMetaData().getParameterCount();
  11:             while(count>0) {
  12:         ...
  13:     public ParameterMetaData getParameterMetaData() throws SQLException {
  14:         return stmt.getParameterMetaData();

View Full Code Here

setArray

public void setArray(int i,
                     Array x)
            throws SQLException
Sets the designated parameter to the given Array object. The driver converts this to an SQL ARRAY value when it sends it to the database.
Parameters:
i - the first parameter is 1, the second is 2, ...
x - an Array object that maps an SQL ARRAY value
Throws:
SQLException - if a database access error occurs
Since:
1.2
Usages and Demos :

View More Examples of setArray(int i,Array x)
   1: import java.sql.Array;
   2: import java.sql.PreparedStatement;
   3: import java.sql.ResultSet;
   4:         ...
   5: 
   6:     public void doFillStatement(PreparedStatement pst, Object value, int index) throws SQLException, IllegalAccessException, InvocationTargetException {
   7:         ...
   8:         pst.setArray(index,(Array)value);
   9:     }

View Full Code Here
   1:         Connection conn = null;
   2:         PreparedStatement pstmt = null;
   3:         java.sql.Array sqlArray = null;
   4:         ...
   5:             pstmt.setString(1, "id300");
   6:             pstmt.setArray(2, sqlArray);
   7: 
   8:             int rowCount = pstmt.executeUpdate();
   9:             System.out.println("rowCount="+rowCount);

View Full Code Here
   1: import java.sql.Date;
   2: import java.sql.PreparedStatement;
   3: import java.sql.Ref;
   4:         ...
   5: 
   6: abstract class C3P0PreparedStatement extends C3P0Statement implements PreparedStatement
   7: {
   8:         ...
   9:     final PreparedStatement inner;
  10: 
  11:         ...
  12:     {
  13:         inner.setArray(a, b);

View Full Code Here
   1: import java.sql.Date;
   2: import java.sql.PreparedStatement;
   3: import java.sql.Ref;
   4:         ...
   5: 
   6: abstract class C3P0PreparedStatement extends C3P0Statement implements PreparedStatement
   7: {
   8:         ...
   9:     final PreparedStatement inner;
  10: 
  11:         ...
  12:     {
  13:         inner.setArray(a, b);

View Full Code Here
   1: public class PreparedStatementAdapter extends StatementAdapter
   2:         implements PreparedStatement
   3:  {
   4:         ...
   5: 
   6:     protected PreparedStatement pstmt;
   7: 
   8:         ...
   9:     public PreparedStatementAdapter(PreparedStatement pstmt) {
  10:         super(pstmt);
  11:         ...
  12:     public void setArray(int i, Array x) throws SQLException {
  13:         pstmt.setArray(i, x);

View Full Code Here

setAsciiStream

public void setAsciiStream(int parameterIndex,
                           InputStream x,
                           int length)
            throws SQLException
Sets the designated parameter to the given input stream, which will have the specified number of bytes. When a very large ASCII value is input to a LONGVARCHAR parameter, it may be more practical to send it via a java.io.InputStream. Data will be read from the stream as needed until end-of-file is reached. The JDBC driver will do any necessary conversion from ASCII to the database char format.

Note: This stream object can either be a standard Java stream object or your own subclass that implements the standard interface.

Parameters:
parameterIndex - the first parameter is 1, the second is 2, ...
x - the Java input stream that contains the ASCII parameter value
length - the number of bytes in the stream
Throws:
SQLException - if a database access error occurs
Usages and Demos :

View More Examples of setAsciiStream(int parameterIndex,java.io.InputStream x,int length)
   1:         Connection conn = null;
   2:         PreparedStatement pstmt = null;
   3:         String query = null;
   4:         ...
   5:             pstmt.setString(1, fileName);
   6:             pstmt.setAsciiStream(2, stream, fileLength);
   7: 
   8:             int rowCount = pstmt.executeUpdate();
   9:             System.out.println("rowCount="+rowCount);

View Full Code Here
   1:         FileInputStream fis  = null;
   2:         PreparedStatement pstmt = null;
   3:         Connection conn = null;
   4:         ...
   5:             pstmt.setString(2, name);
   6:             pstmt.setAsciiStream(3, fis,(int)file.length());
   7:             pstmt.executeUpdate();
   8:             conn.commit();
   9:         }

View Full Code Here
   1:         FileInputStream fis  = null;
   2:         PreparedStatement pstmt = null;
   3:         Connection conn = null;
   4:         ...
   5:             pstmt.setString(2, name);
   6:             pstmt.setAsciiStream(3, fis,(int)file.length());
   7:             pstmt.executeUpdate();
   8:             conn.commit();
   9:         }

View Full Code Here
   1: import java.math.BigDecimal;
   2: import java.sql.PreparedStatement;
   3: import java.sql.ResultSet;
   4:         ...
   5: {
   6:     public void setObjectForStatement(PreparedStatement ps, int index, Object value, int sqlType)
   7:         throws SQLException
   8:         ...
   9:                 ByteArrayInputStream bais = new ByteArrayInputStream(bytes);                
  10:                 ps.setAsciiStream(index, bais, bytes.length);
  11:             }

View Full Code Here
   1: import java.sql.Date;
   2: import java.sql.PreparedStatement;
   3: import java.sql.Ref;
   4:         ...
   5: 
   6: abstract class C3P0PreparedStatement extends C3P0Statement implements PreparedStatement
   7: {
   8:         ...
   9:     final PreparedStatement inner;
  10: 
  11:         ...
  12:     {
  13:         inner.setAsciiStream(a, b, c);

View Full Code Here

setBigDecimal

public void setBigDecimal(int parameterIndex,
                          BigDecimal x)
            throws SQLException
Sets the designated parameter to the given java.math.BigDecimal value. The driver converts this to an SQL NUMERIC value when it sends it to the database.
Parameters:
parameterIndex - the first parameter is 1, the second is 2, ...
x - the parameter value
Throws:
SQLException - if a database access error occurs
Usages and Demos :

View More Examples of setBigDecimal(int parameterIndex,BigDecimal x)
   1: import java.sql.Connection;
   2: import java.sql.PreparedStatement;
   3: import java.sql.Statement;
   4:         ...
   5:       Connection conn = null;
   6:       PreparedStatement ps = null;
   7:       conn = DatabaseConnectionFactory.getConnection();
   8:         ...
   9:                   materialLink.setElementId(elementDef.getClassName());
  10:                   ps.setBigDecimal(1, materialLink.getMaterialId());
  11:                   ps.setString(2, materialLink.getMaterialName());
  12:         ...
  13:                   ps.setString(4, elementDef.getClassName());
  14:                   ps.setBigDecimal(5, materialLink.getSampleId());

View Full Code Here
   1: 
   2: import java.sql.PreparedStatement;
   3: 
   4:         ...
   5: 
   6:         PreparedStatement ps = connection.prepareStatement(UPDATE_RECORD);
   7: 
   8:         ...
   9:         ps.setBigDecimal(1, test);

View Full Code Here
   1: import java.math.BigDecimal;
   2: import java.sql.PreparedStatement;
   3: import java.sql.SQLException;
   4:         ...
   5:     public void cleanUpBeforeStart() {
   6:         PreparedStatement preparedStatement=null;
   7:         try {
   8:         ...
   9:                 List beanItem = (List) data.get(i);
  10:                 preparedStatement.setBigDecimal(1, (BigDecimal) beanItem.get(0));
  11:         ...
  12:                 preparedStatement.setBigDecimal(2, (BigDecimal) beanItem.get(1));

View Full Code Here
   1:                 "insert into savingsaccount values ( ? , ? , ? , ? )";
   2:           PreparedStatement prepStmt = 
   3:                 con.prepareStatement(insertStatement);
   4:         ...
   5:           prepStmt.setString(3, lastName);
   6:           prepStmt.setBigDecimal(4, balance);
   7: 
   8:         ...
   9:             "delete from savingsaccount where id = ? ";
  10:       PreparedStatement prepStmt =
  11:             con.prepareStatement(deleteStatement);
  12:         ...
  13:             "from savingsaccount where id = ? ";
  14:       PreparedStatement prepStmt =

View Full Code Here
   1: import java.sql.SQLException;
   2: import java.sql.PreparedStatement;
   3: import java.sql.ResultSet;
   4:         ...
   5:         Connection conn = null;
   6:         PreparedStatement ps = null;
   7:         ResultSet rs = null;
   8:         ...
   9:         Connection conn = null;
  10:         PreparedStatement ps = null;
  11:         ResultSet rs = null;
  12:         ...
  13:             ps.setString(1, personId);
  14:             ps.setBigDecimal(2, entryId);

View Full Code Here

setBinaryStream

public void setBinaryStream(int parameterIndex,
                            InputStream x,
                            int length)
            throws SQLException
Sets the designated parameter to the given input stream, which will have the specified number of bytes. When a very large binary value is input to a LONGVARBINARY parameter, it may be more practical to send it via a java.io.InputStream object. The data will be read from the stream as needed until end-of-file is reached.

Note: This stream object can either be a standard Java stream object or your own subclass that implements the standard interface.

Parameters:
parameterIndex - the first parameter is 1, the second is 2, ...
x - the java input stream which contains the binary parameter value
length - the number of bytes in the stream
Throws:
SQLException - if a database access error occurs
Usages and Demos :

View More Examples of setBinaryStream(int parameterIndex,java.io.InputStream x,int length)
   1: 
   2:         PreparedStatement pstmt = null;
   3:         try {
   4:         ...
   5:             pstmt = conn.prepareStatement(UPDATE_PICTURE);
   6:             pstmt.setBinaryStream(1, photo, photo.available());
   7:             pstmt.setString(2, id);
   8:             pstmt.executeUpdate();
   9:             conn.commit();

View Full Code Here
   1: import java.sql.Statement;
   2: import java.sql.PreparedStatement;
   3: import java.sql.SQLException;
   4:         ...
   5:             String updcmd = "UPDATE HKSTABLE SET " + type + " = ? WHERE USERID LIKE '" + username + "'";
   6:             PreparedStatement stmt1 = con.prepareStatement(updcmd);
   7:         ...
   8:             stmt1.setBinaryStream(1, ksfis, nbytes);
   9:             stmt1.executeUpdate();

View Full Code Here
   1: import java.io.StringReader;
   2: import java.sql.PreparedStatement;
   3: import java.sql.SQLException;
   4:         ...
   5: 
   6:         MockControl psControl = MockControl.createControl(PreparedStatement.class);
   7:         ...
   8:         PreparedStatement ps = (PreparedStatement) psControl.getMock();
   9:         ps.setBytes(1, content);
  10:         ...
  11:         PreparedStatement ps = (PreparedStatement) psControl.getMock();
  12:         ps.setBinaryStream(1, bis, 11);

View Full Code Here
   1: import java.sql.Statement;
   2: import java.sql.PreparedStatement;
   3: import java.util.Arrays;
   4:         ...
   5:     protected void checkReadBlob(String name) throws Exception {
   6:         PreparedStatement p = c.prepareStatement("select * from " + name + " where C1 = ?");
   7:         p.setInt(1, 1);
   8:         ...
   9:         t.begin();
  10:         PreparedStatement p = c.prepareStatement("insert into T1 values (?, ?)");
  11:         Blob blob = c.createBlob();
  12:         ...
  13:         InputStream bais = new ByteArrayInputStream(testbuf);
  14:         p.setBinaryStream(2, bais, bloblength);

View Full Code Here
   1:     Statement stmt = null;
   2:     PreparedStatement ps = null;
   3:     ResultSet rs = null;
   4:         ...
   5:       ps = conn.prepareStatement("insert into WLLongVarChar values(?)");
   6:       ps.setBinaryStream(1, fis, fis.available());
   7: 
   8:       ps.executeUpdate();
   9:       ps.close();

View Full Code Here

setBlob

public void setBlob(int i,
                    Blob x)
            throws SQLException
Sets the designated parameter to the given Blob object. The driver converts this to an SQL BLOB value when it sends it to the database.
Parameters:
i - the first parameter is 1, the second is 2, ...
x - a Blob object that maps an SQL BLOB value
Throws:
SQLException - if a database access error occurs
Since:
1.2
Usages and Demos :

View More Examples of setBlob(int i,Blob x)
   1: 
   2:           PreparedStatement ps;
   3:           ps = con.prepareStatement ("insert into employee(name,photo) "+
   4:         ...
   5:               oos.close ();
   6:               ps.setBlob(2, blob);
   7:               ps.execute ();
   8:           }
   9:           catch (Exception ex)

View Full Code Here
   1: import java.sql.Blob;
   2: import java.sql.PreparedStatement;
   3: import java.sql.ResultSet;
   4:         ...
   5:     
   6:     public void set(PreparedStatement st, Object value, int index) throws HibernateException, SQLException {
   7:         if (value instanceof BlobImpl) {
   8:         ...
   9:         else {
  10:             st.setBlob(index, (Blob) value);
  11:         }

View Full Code Here
   1: import java.sql.Blob;
   2: import java.sql.PreparedStatement;
   3: import java.sql.ResultSet;
   4:         ...
   5: 
   6:     public void set(PreparedStatement st, Object value, int index) throws HibernateException, SQLException {
   7:         if (value instanceof BlobImpl) {
   8:         ...
   9:         else {
  10:             st.setBlob(index, (Blob) value);
  11:         }

View Full Code Here
   1:         Connection conn = null;
   2:         PreparedStatement pstmt = null;
   3:         ResultSet rs = null;
   4:         ...
   5:             pstmt.setString(1, id);
   6:             pstmt.setBlob(2, blob);
   7: 
   8:             int rowCount = pstmt.executeUpdate();
   9:             System.out.println("rowCount="+rowCount);

View Full Code Here
   1: import java.sql.Connection;
   2: import java.sql.PreparedStatement;
   3: import java.sql.ResultSet;
   4:         ...
   5:             JMSException {
   6:         PreparedStatement s = null;
   7:         ResultSet rs = null;
   8:         ...
   9:             s = c.prepareStatement(statementProvider.getUpdateMessageStatment());
  10:             s.setBlob(1, blob);
  11:             s.setLong(2, seq);
  12:         ...
  13:     public byte[] doGetMessage(Connection c, long seq) throws SQLException {
  14:         PreparedStatement s=null; ResultSet rs=null;

View Full Code Here

setBoolean

public void setBoolean(int parameterIndex,
                       boolean x)
            throws SQLException
Sets the designated parameter to the given Java boolean value. The driver converts this to an SQL BIT value when it sends it to the database.
Parameters:
parameterIndex - the first parameter is 1, the second is 2, ...
x - the parameter value
Throws:
SQLException - if a database access error occurs
Usages and Demos :

View More Examples of setBoolean(int parameterIndex,boolean x)
   1: import java.sql.Connection;
   2: import java.sql.PreparedStatement;
   3: import java.sql.ResultSet;
   4:         ...
   5:   public void buildList(Connection db) throws SQLException {
   6:     PreparedStatement pst = null;
   7:     ResultSet rs = null;
   8:         ...
   9: 
  10:   protected int prepareFilter(PreparedStatement pst) throws SQLException {
  11:     int i = 0;
  12:         ...
  13:     if (enabled != Constants.UNDEFINED) {
  14:       pst.setBoolean(++i, enabled == Constants.TRUE);

View Full Code Here
   1:         "VALUES (" + getValues(18) + ")";
   2:       PreparedStatement pst = db.prepareStatement(sql);
   3:       int i = 0;
   4:         ...
   5:       pst.setInt(++i, owner);
   6:       pst.setBoolean(++i, enabled);
   7:       pst.setString(++i, subject);
   8:         ...
   9:       pst.setDate(++i, end);
  10:       pst.setBoolean(++i, allDayEvent);
  11:         ...
  12:       pst.setBoolean(++i, isRecurring);

View Full Code Here
   1: import java.sql.Connection;
   2: import java.sql.PreparedStatement;
   3: import java.sql.ResultSet;
   4:         ...
   5:   public void buildList(Connection db) throws SQLException {
   6:     PreparedStatement pst = null;
   7:     ResultSet rs = null;
   8:         ...
   9: 
  10:   private int prepareFilter(PreparedStatement pst) throws SQLException {
  11:     int i = 0;
  12:         ...
  13:     if (enabled != Constants.UNDEFINED) {
  14:       pst.setBoolean(++i, (enabled == Constants.TRUE));

View Full Code Here
   1: import java.sql.Connection;
   2: import java.sql.PreparedStatement;
   3: import java.sql.ResultSet;
   4:         ...
   5:   public void buildList(Connection db) throws SQLException {
   6:     PreparedStatement pst = null;
   7:     ResultSet rs = null;
   8:         ...
   9: 
  10:   private int prepareFilter(PreparedStatement pst) throws SQLException {
  11:     int i = 0;
  12:         ...
  13:     if (enabled != Constants.UNDEFINED) {
  14:       pst.setBoolean(++i, (enabled == Constants.TRUE));

View Full Code Here
   1: import java.sql.Connection;
   2: import java.sql.PreparedStatement;
   3: import java.sql.ResultSet;
   4:         ...
   5:   public void queryRecord(Connection db, int reportId) throws SQLException {
   6:     PreparedStatement pst = db.prepareStatement(
   7:         "SELECT r.* " +
   8:         ...
   9:     int reportId = -1;
  10:     PreparedStatement pst = db.prepareStatement(
  11:         "SELECT report_id " +
  12:         ...
  13:     DatabaseUtils.setInt(pst, ++i, modifiedBy);
  14:     pst.setBoolean(++i, enabled);

View Full Code Here

setByte

public void setByte(int parameterIndex,
                    byte x)
            throws SQLException
Sets the designated parameter to the given Java byte value. The driver converts this to an SQL TINYINT value when it sends it to the database.
Parameters:
parameterIndex - the first parameter is 1, the second is 2, ...
x - the parameter value
Throws:
SQLException - if a database access error occurs
Usages and Demos :

View More Examples of setByte(int parameterIndex,byte x)
   1: import java.lang.reflect.InvocationTargetException;
   2: import java.sql.PreparedStatement;
   3: import java.sql.ResultSet;
   4:         ...
   5: 
   6:     public void doFillStatement(PreparedStatement pst, Object value, int index) throws SQLException, IllegalAccessException, InvocationTargetException {
   7:         ...
   8:         pst.setByte(index,((Byte)value).byteValue());
   9:     }

View Full Code Here
   1: import java.io.Serializable;
   2: import java.sql.PreparedStatement;
   3: import java.sql.ResultSet;
   4:         ...
   5: 
   6:     public void set(PreparedStatement st, Object value, int index) throws SQLException {
   7:         ...
   8:         st.setByte( index, ( (Byte) value ).byteValue() );
   9:     }

View Full Code Here
   1:         Connection conn = null;
   2:         PreparedStatement pstmt = null;
   3:         try {
   4:         ...
   5:             pstmt.setString(1, id);
   6:             pstmt.setByte(2, byteValue);
   7:             pstmt.setShort(3, shortValue);
   8:             pstmt.setInt(4, intValue);
   9:             pstmt.setLong(5, longValue);

View Full Code Here
   1: import java.sql.Date;
   2: import java.sql.PreparedStatement;
   3: import java.sql.Ref;
   4:         ...
   5: 
   6: abstract class C3P0PreparedStatement extends C3P0Statement implements PreparedStatement
   7: {
   8:         ...
   9:     final PreparedStatement inner;
  10: 
  11:         ...
  12:     {
  13:         inner.setByte(a, b);

View Full Code Here
   1: import java.sql.Date;
   2: import java.sql.PreparedStatement;
   3: import java.sql.Ref;
   4:         ...
   5: 
   6: abstract class C3P0PreparedStatement extends C3P0Statement implements PreparedStatement
   7: {
   8:         ...
   9:     final PreparedStatement inner;
  10: 
  11:         ...
  12:     {
  13:         inner.setByte(a, b);

View Full Code Here

setBytes

public void setBytes(int parameterIndex,
                     x[] )
            throws SQLException
Sets the designated parameter to the given Java array of bytes. The driver converts this to an SQL VARBINARY or LONGVARBINARY (depending on the argument's size relative to the driver's limits on VARBINARY values) when it sends it to the database.
Parameters:
parameterIndex - the first parameter is 1, the second is 2, ...
Throws:
SQLException - if a database access error occurs
Usages and Demos :

View More Examples of setBytes(int parameterIndex,x[] )
   1: import java.io.StringReader;
   2: import java.sql.PreparedStatement;
   3: import java.sql.SQLException;
   4:         ...
   5: 
   6:         MockControl psControl = MockControl.createControl(PreparedStatement.class);
   7:         ...
   8:         PreparedStatement ps = (PreparedStatement) psControl.getMock();
   9:         ...
  10:         ps.setBytes(1, content);

View Full Code Here
   1: import java.sql.Connection;
   2: import java.sql.PreparedStatement;
   3: import java.sql.ResultSet;
   4:         ...
   5:         Connection con = null;
   6:         PreparedStatement pstmt = null;
   7:         try {
   8:         ...
   9:         Connection con = null;
  10:         PreparedStatement pstmt = null;
  11:         try {
  12:         ...
  13:             pstmt = con.prepareStatement(saveAttachmentSQL);
  14:             pstmt.setBytes(1, data);

View Full Code Here
   1: 
   2:         PreparedStatement pstmt = null;
   3:         success = true;
   4:         ...
   5:             else
   6:                 pstmt.setBytes(1, (byte[])m_value);
   7:             int no = pstmt.executeUpdate();
   8:             if (no != 1)
   9:             {

View Full Code Here
   1: 
   2: import java.sql.PreparedStatement;
   3: 
   4:         ...
   5: 
   6:         final PreparedStatement statement =
   7: 
   8:         ...
   9: 
  10:         statement.setBytes(1, guid);
  11: 
  12:         ...
  13: 
  14:         final PreparedStatement statement =

View Full Code Here
   1: import java.sql.DriverManager;
   2: import java.sql.PreparedStatement;
   3: import java.sql.ResultSet;
   4:         ...
   5: 
   6:         PreparedStatement prep = null;
   7:         try
   8:         ...
   9: 
  10:         PreparedStatement prep = null;
  11:         try
  12:         ...
  13:                     + bigObject.length);
  14:             prep.setBytes(1, bigObject);

View Full Code Here

setCharacterStream

public void setCharacterStream(int parameterIndex,
                               Reader reader,
                               int length)
            throws SQLException
Sets the designated parameter to the given Reader object, which is the given number of characters long. When a very large UNICODE value is input to a LONGVARCHAR parameter, it may be more practical to send it via a java.io.Reader object. The data will be read from the stream as needed until end-of-file is reached. The JDBC driver will do any necessary conversion from UNICODE to the database char format.

Note: This stream object can either be a standard Java stream object or your own subclass that implements the standard interface.

Parameters:
parameterIndex - the first parameter is 1, the second is 2, ...
reader - the java.io.Reader object that contains the Unicode data
length - the number of characters in the stream
Throws:
SQLException - if a database access error occurs
Since:
1.2
Usages and Demos :

View More Examples of setCharacterStream(int parameterIndex,java.io.Reader reader,int length)
   1: import java.io.StringReader;
   2: import java.sql.PreparedStatement;
   3: import java.sql.ResultSet;
   4:         ...
   5: 
   6:     public void nullSafeSet(PreparedStatement st, Object value, int index) throws HibernateException, SQLException {
   7:         if ( value != null ) {
   8:         ...
   9:             StringReader reader = new StringReader( string );
  10:             st.setCharacterStream( index, reader, string.length() );
  11:         }

View Full Code Here
   1:         Connection conn = null;
   2:         PreparedStatement pstmt = null;
   3:         try {
   4:         ...
   5:             pstmt.setString(1, fileName);
   6:             pstmt.setCharacterStream(2, fileReader, (int)fileLength);
   7: 
   8:             int rowCount = pstmt.executeUpdate();
   9:             System.out.println("rowCount="+rowCount);

View Full Code Here
   1: import java.io.StringReader;
   2: import java.sql.PreparedStatement;
   3: import java.sql.ResultSet;
   4:         ...
   5: 
   6:     public void nullSafeSet(PreparedStatement st, Object value, int index)
   7:             throws HibernateException, SQLException {
   8:         ...
   9:             StringReader r = new StringReader((String) value);
  10:             st.setCharacterStream(index, r, ((String) value).length());
  11:         } else {

View Full Code Here
   1: import java.io.Serializable;
   2: import java.sql.PreparedStatement;
   3: import java.sql.ResultSet;
   4:         ...
   5: 
   6:     public void nullSafeSet(PreparedStatement st, Object value, int index) throws HibernateException, SQLException {
   7:         if ( value != null ) {
   8:         ...
   9:             CharArrayReader reader = new CharArrayReader( chars );
  10:             st.setCharacterStream( index, reader, chars.length );
  11:         }

View Full Code Here
   1: import java.io.StringReader;
   2: import java.sql.PreparedStatement;
   3: import java.sql.SQLException;
   4:         ...
   5:     
   6:     public void setObjectForStatement(PreparedStatement ps, int index, Object value, int sqlType) throws SQLException
   7:     {
   8:         ...
   9: 
  10:                 ps.setCharacterStream(index, reader, length);
  11:                 break;

View Full Code Here

setClob

public void setClob(int i,
                    Clob x)
            throws SQLException
Sets the designated parameter to the given Clob object. The driver converts this to an SQL CLOB value when it sends it to the database.
Parameters:
i - the first parameter is 1, the second is 2, ...
x - a Clob object that maps an SQL CLOB value
Throws:
SQLException - if a database access error occurs
Since:
1.2
Usages and Demos :

View More Examples of setClob(int i,Clob x)
   1:   public static void free(Connection conn, Clob clob) {
   2:     PreparedStatement PS = null;
   3:     try {
   4:         ...
   5:       PS = conn.prepareStatement("begin dbms_lob.freetemporary(?);end;");
   6:       PS.setClob(1,clob);
   7:       int rows = PS.executeUpdate();
   8:       PS.close();
   9:     }

View Full Code Here
   1:         Connection conn = null;
   2:         PreparedStatement pstmt = null;
   3:         try {
   4:         ...
   5:             pstmt.setString(1, newID);
   6:             pstmt.setClob(2, clob);
   7: 
   8:             int rowCount = pstmt.executeUpdate();
   9:             System.out.println("rowCount="+rowCount);

View Full Code Here
   1: import java.sql.Date;
   2: import java.sql.PreparedStatement;
   3: import java.sql.Ref;
   4:         ...
   5: 
   6: abstract class C3P0PreparedStatement extends C3P0Statement implements PreparedStatement
   7: {
   8:         ...
   9:     final PreparedStatement inner;
  10: 
  11:         ...
  12:     {
  13:         inner.setClob(a, b);

View Full Code Here
   1: import java.sql.Date;
   2: import java.sql.PreparedStatement;
   3: import java.sql.Ref;
   4:         ...
   5: 
   6: abstract class C3P0PreparedStatement extends C3P0Statement implements PreparedStatement
   7: {
   8:         ...
   9:     final PreparedStatement inner;
  10: 
  11:         ...
  12:     {
  13:         inner.setClob(a, b);

View Full Code Here
   1: public class PreparedStatementAdapter extends StatementAdapter
   2:         implements PreparedStatement
   3:  {
   4:         ...
   5: 
   6:     protected PreparedStatement pstmt;
   7: 
   8:         ...
   9:     public PreparedStatementAdapter(PreparedStatement pstmt) {
  10:         super(pstmt);
  11:         ...
  12:     public void setClob(int i, Clob x) throws SQLException {
  13:         pstmt.setClob(i, x);

View Full Code Here

setDate

public void setDate(int parameterIndex,
                    Date x)
            throws SQLException
Sets the designated parameter to the given java.sql.Date value. The driver converts this to an SQL DATE value when it sends it to the database.
Parameters:
parameterIndex - the first parameter is 1, the second is 2, ...
x - the parameter value
Throws:
SQLException - if a database access error occurs
Usages and Demos :

View More Examples of setDate(int parameterIndex,java.sql.Date x)
   1: import java.sql.Connection;
   2: import java.sql.PreparedStatement;
   3: import java.sql.Statement;
   4:         ...
   5:         Connection conn = null;
   6:         PreparedStatement cmd = null;
   7:         CallableStatement stm_c = null;
   8:         ...
   9:             cmd = conn.prepareStatement(SQL);
  10:             cmd.setDate(1,Routine.getSQLDate(f.getAudoc_date()));
  11:             cmd.setString(2,f.getAudoc_desc1());

View Full Code Here
   1: import java.sql.Connection;
   2: import java.sql.PreparedStatement;
   3: import java.sql.Statement;
   4:         ...
   5:         Connection conn = null;
   6:         PreparedStatement cmd = null;
   7:         CallableStatement stm_c = null;
   8:         ...
   9:             cmd = conn.prepareStatement(SQL);
  10:             cmd.setDate(1,Routine.getSQLDate(f.getRefuse_date()));
  11:             cmd.setString(2,Util.Iso88591ToTis(f.getRefuse_desc1()));

View Full Code Here
   1: import java.sql.Connection;
   2: import java.sql.PreparedStatement;
   3: import java.sql.Statement;
   4:         ...
   5:         Connection conn = null;
   6:         PreparedStatement cmd = null;
   7:         Statement stm = null;
   8:         ...
   9: 
  10:             cmd.setDate(1,Routine.getSQLDate(f.getRegisDate()));
  11:             cmd.setString(2,Util.Iso88591ToTis(f.getRegis_ps()));

View Full Code Here
   1: 
   2: import java.sql.PreparedStatement;
   3: import java.sql.SQLException;
   4:         ...
   5:     private MockControl psControl;
   6:     private PreparedStatement ps;
   7: 
   8:         ...
   9:     protected void setUp() {
  10:         psControl = MockControl.createControl(PreparedStatement.class);
  11:         ps = (PreparedStatement) psControl.getMock();
  12:         ...
  13:         java.sql.Date date = new java.sql.Date(1000);
  14:         ps.setDate(1, date);

View Full Code Here
   1:         "VALUES (" + getValues(16) + ")";
   2:       PreparedStatement pst = db.prepareStatement(sql);
   3:       int i = 0;
   4:         ...
   5:       pst.setString(++i, categories);
   6:       pst.setDate(++i, startDate);
   7:         ...
   8:       pst.setDate(++i, dueDate);
   9:         ...
  10:       pst.setDate(++i, dateCompleted);

View Full Code Here

setDate

public void setDate(int parameterIndex,
                    Date x,
                    Calendar cal)
            throws SQLException
Sets the designated parameter to the given java.sql.Date value, using the given Calendar object. The driver uses the Calendar object to construct an SQL DATE value, which the driver then sends to the database. With a Calendar object, the driver can calculate the date taking into account a custom timezone. If no Calendar object is specified, the driver uses the default timezone, which is that of the virtual machine running the application.
Parameters:
parameterIndex - the first parameter is 1, the second is 2, ...
x - the parameter value
cal - the Calendar object the driver will use to construct the date
Throws:
SQLException - if a database access error occurs
Since:
1.2
Usages and Demos :

View More Examples of setDate(int parameterIndex,java.sql.Date x,Calendar cal)
   1: import java.sql.Date;
   2: import java.sql.PreparedStatement;
   3: import java.sql.Ref;
   4:         ...
   5: 
   6: abstract class C3P0PreparedStatement extends C3P0Statement implements PreparedStatement
   7: {
   8:         ...
   9:     final PreparedStatement inner;
  10: 
  11:         ...
  12:     {
  13:         inner.setDate(a, b, c);

View Full Code Here
   1: import java.sql.Date;
   2: import java.sql.PreparedStatement;
   3: import java.sql.Ref;
   4:         ...
   5: 
   6: abstract class C3P0PreparedStatement extends C3P0Statement implements PreparedStatement
   7: {
   8:         ...
   9:     final PreparedStatement inner;
  10: 
  11:         ...
  12:     {
  13:         inner.setDate(a, b, c);

View Full Code Here
   1: public class PreparedStatementAdapter extends StatementAdapter
   2:         implements PreparedStatement
   3:  {
   4:         ...
   5: 
   6:     protected PreparedStatement pstmt;
   7: 
   8:         ...
   9:     public PreparedStatementAdapter(PreparedStatement pstmt) {
  10:         super(pstmt);
  11:         ...
  12:     {
  13:         pstmt.setDate(parameterIndex, x, cal);

View Full Code Here
   1: import java.sql.ParameterMetaData;
   2: import java.sql.PreparedStatement;
   3: import java.sql.Ref;
   4:         ...
   5: 
   6: public abstract class FilterPreparedStatement implements PreparedStatement
   7: {
   8:         ...
   9:     protected PreparedStatement inner;
  10:     
  11:         ...
  12:     public void setDate(int a, Date b, Calendar c) throws SQLException
  13:     { inner.setDate(a, b, c); }

View Full Code Here
   1: import java.sql.ParameterMetaData;
   2: import java.sql.PreparedStatement;
   3: import java.sql.Ref;
   4:         ...
   5: 
   6: public abstract class SynchronizedFilterPreparedStatement implements PreparedStatement
   7: {
   8:         ...
   9:     protected PreparedStatement inner;
  10:     
  11:         ...
  12:     public synchronized void setDate(int a, Date b, Calendar c) throws SQLException
  13:     { inner.setDate(a, b, c); }

View Full Code Here

setDouble

public void setDouble(int parameterIndex,
                      double x)
            throws SQLException
Sets the designated parameter to the given Java double value. The driver converts this to an SQL DOUBLE value when it sends it to the database.
Parameters:
parameterIndex - the first parameter is 1, the second is 2, ...
x - the parameter value
Throws:
SQLException - if a database access error occurs
Usages and Demos :

View More Examples of setDouble(int parameterIndex,double x)
   1:   public void insert(Connection db) throws SQLException {
   2:     PreparedStatement pst = db.prepareStatement(
   3:         "INSERT INTO timesheet_projects " +
   4:         ...
   5:     DatabaseUtils.setInt(pst, ++i, projectId);
   6:     pst.setDouble(++i, hours);
   7:     pst.execute();
   8:     pst.close();
   9:     id = DatabaseUtils.getCurrVal(db, "timesheet_projects_id_seq", -1);

View Full Code Here
   1: import java.sql.Connection;
   2: import java.sql.PreparedStatement;
   3: import java.sql.SQLException;
   4:         ...
   5:   public boolean insert(Connection db) throws SQLException {
   6:     PreparedStatement pst = db.prepareStatement(
   7:         "INSERT INTO customer_order_payment " +
   8:         ...
   9:     pst.setInt(++i, creditCard.getExpirationYear());
  10:     pst.setDouble(++i, chargeAmount);
  11:     pst.execute();
  12:         ...
  13:   public boolean updateProcessed(Connection db) throws SQLException {
  14:     PreparedStatement pst = db.prepareStatement(

View Full Code Here
   1:     }
   2:     PreparedStatement pst = db.prepareStatement(
   3:         "SELECT item_id, version, user_download_id, download_date " +
   4:         ...
   5:   public boolean insert(Connection db) throws SQLException {
   6:     PreparedStatement pst = db.prepareStatement(
   7:         "INSERT INTO project_files_download " +
   8:         ...
   9:     pst.setInt(++i, itemId);
  10:     pst.setDouble(++i, version);
  11:     pst.setInt(++i, userId);
  12:         ...
  13:     }
  14:     PreparedStatement pst = db.prepareStatement(

View Full Code Here
   1: import java.sql.Connection;
   2: import java.sql.PreparedStatement;
   3: import java.sql.SQLException;
   4:         ...
   5:   public boolean insert(Connection db) throws SQLException {
   6:     PreparedStatement pst = db.prepareStatement(
   7:         "INSERT INTO project_files_thumbnail " +
   8:         ...
   9:     pst.setString(++i, filename);
  10:     pst.setDouble(++i, version);
  11:     pst.setInt(++i, size);
  12:         ...
  13:         "AND version = ? ";
  14:     PreparedStatement pst = db.prepareStatement(sql);

View Full Code Here
   1: import java.sql.Connection;
   2: import java.sql.PreparedStatement;
   3: import java.sql.ResultSet;
   4:         ...
   5:     }
   6:     PreparedStatement pst = db.prepareStatement(
   7:         "SELECT co.* " +
   8:         ...
   9:   public boolean insert(Connection db) throws SQLException {
  10:     PreparedStatement pst = db.prepareStatement(
  11:         "INSERT INTO customer_order_product_options " +
  12:         ...
  13:     pst.setString(++i, defaultValue);
  14:     pst.setDouble(++i, this.getAmount());

View Full Code Here

setFloat

public void setFloat(int parameterIndex,
                     float x)
            throws SQLException
Sets the designated parameter to the given Java float value. The driver converts this to an SQL FLOAT value when it sends it to the database.
Parameters:
parameterIndex - the first parameter is 1, the second is 2, ...
x - the parameter value
Throws:
SQLException - if a database access error occurs
Usages and Demos :

View More Examples of setFloat(int parameterIndex,float x)
   1:         Connection conn = null;
   2:         PreparedStatement pstmt = null;
   3:         try {
   4:         ...
   5:             pstmt.setString(1, stringValue);
   6:             pstmt.setFloat(2, floatValue);
   7:             pstmt.setDouble(3, doubleValue);
   8: 
   9:             int rowCount = pstmt.executeUpdate();

View Full Code Here
   1:     Connection connection = null;
   2:     PreparedStatement statement = null;
   3:     try {
   4:         ...
   5:       statement.setString(1, _name);
   6:       statement.setFloat(2, _balance);
   7:       if (statement.executeUpdate() != 1) {
   8:         ...
   9:     Connection connection = null;
  10:     PreparedStatement statement = null;
  11:     try {
  12:         ...
  13:     Connection connection = null;
  14:     PreparedStatement statement = null;

View Full Code Here
   1: 
   2: import java.sql.PreparedStatement;
   3: import java.sql.ResultSet;
   4:         ...
   5: 
   6:             PreparedStatement pStmt = this.conn.prepareStatement(
   7:                     "INSERT INTO pStmtClip VALUES (?, ?)");
   8:         ...
   9:             pStmt.setDouble(1, Double.NEGATIVE_INFINITY);
  10:             pStmt.setFloat(2, Float.NEGATIVE_INFINITY);
  11:             System.out.println(pStmt.toString());
  12:         ...
  13:             pStmt.setDouble(1, Double.POSITIVE_INFINITY);
  14:             pStmt.setFloat(2, Float.POSITIVE_INFINITY);

View Full Code Here
   1:         Statement stat=conn.createStatement();
   2:         PreparedStatement prep;
   3:         ResultSet rs;
   4:         ...
   5:         prep.setInt(1,3);
   6:         prep.setFloat(2,10);
   7:         prep.executeUpdate();
   8:         ...
   9:         prep.setInt(1,4);
  10:         prep.setFloat(2,-20);
  11:         prep.executeUpdate();
  12:         ...
  13:         prep.setInt(1,5);
  14:         prep.setFloat(2,30);

View Full Code Here

setInt

public void setInt(int parameterIndex,
                   int x)
            throws SQLException
Sets the designated parameter to the given Java int value. The driver converts this to an SQL INTEGER value when it sends it to the database.
Parameters:
parameterIndex - the first parameter is 1, the second is 2, ...
x - the parameter value
Throws:
SQLException - if a database access error occurs
Usages and Demos :

View More Examples of setInt(int parameterIndex,int x)
   1: import java.sql.Connection;
   2: import java.sql.PreparedStatement;
   3: import java.sql.ResultSet;
   4:         ...
   5:     sql.append("ORDER BY category_id, level, description ");
   6:     PreparedStatement pst = db.prepareStatement(sql.toString());
   7:     prepareFilter(pst);
   8:         ...
   9: 
  10:   private int prepareFilter(PreparedStatement pst) throws SQLException {
  11:     int i = 0;
  12:         ...
  13:     if (categoryId > -1) {
  14:       pst.setInt(++i, categoryId);

View Full Code Here
   1:   public void insert(Connection db) throws SQLException {
   2:     PreparedStatement pst = db.prepareStatement("INSERT INTO project_assignments_status " +
   3:         "(assignment_id, user_id, description, percent_complete, project_status_id) " +
   4:         ...
   5:     int i = 0;
   6:     pst.setInt(++i, assignmentId);
   7:         ...
   8:     pst.setInt(++i, userId);
   9:     pst.setString(++i, description);
  10:         ...
  11:     pst.setInt(++i, percentComplete);

View Full Code Here
   1: import java.sql.Connection;
   2: import java.sql.PreparedStatement;
   3: import java.sql.ResultSet;
   4:         ...
   5:   public void insert(Connection db) throws SQLException {
   6:     PreparedStatement pst = db.prepareStatement(
   7:         "INSERT INTO project_assignments_user " +
   8:         ...
   9:     int i = 0;
  10:     pst.setInt(++i, assignmentId);
  11:         ...
  12:     pst.setInt(++i, userId);

View Full Code Here
   1: import java.sql.Connection;
   2: import java.sql.PreparedStatement;
   3: import java.sql.SQLException;
   4:         ...
   5:   public static void delete(Connection db, int assignmentId) throws SQLException {
   6:     PreparedStatement pst = db.prepareStatement("DELETE FROM project_assignments_status " +
   7:         "WHERE assignment_id = ? ");
   8:         ...
   9:     pst.setInt(1, assignmentId);
  10:     pst.execute();
  11:         ...
  12:     int count = 0;
  13:     PreparedStatement pst = db.prepareStatement("SELECT count(*) AS rec_count " +

View Full Code Here
   1:     sqlOrder.append("ORDER BY event_id ");
   2:     PreparedStatement pst = db.prepareStatement(sqlSelect.toString() + sqlFilter.toString() + sqlOrder.toString());
   3:     prepareFilter(pst);
   4:         ...
   5: 
   6:   private int prepareFilter(PreparedStatement pst) throws SQLException {
   7:     int i = 0;
   8:         ...
   9:     if (businessProcessId > -1) {
  10:       pst.setInt(++i, businessProcessId);
  11:     }

View Full Code Here

setLong

public void setLong(int parameterIndex,
                    long x)
            throws SQLException
Sets the designated parameter to the given Java long value. The driver converts this to an SQL BIGINT value when it sends it to the database.
Parameters:
parameterIndex - the first parameter is 1, the second is 2, ...
x - the parameter value
Throws:
SQLException - if a database access error occurs
Usages and Demos :

View More Examples of setLong(int parameterIndex,long x)
   1: 
   2: import java.sql.PreparedStatement;
   3: import java.sql.ResultSet;
   4:         ...
   5:     private ZeroForNullLongType type;
   6:     private PreparedStatement stmt;
   7:     private ResultSet result;
   8:         ...
   9:         type = new ZeroForNullLongType();
  10:         stmt = (PreparedStatement) createMock(PreparedStatement.class);
  11:         result = (ResultSet) createMock(ResultSet.class);
  12:         ...
  13:     public void testNullSafeSetNull() throws Exception {
  14:         stmt.setLong(1, 0);

View Full Code Here
   1: 
   2: import java.sql.PreparedStatement;
   3: import java.sql.ResultSet;
   4:         ...
   5:     private ZeroForNullLongType type;
   6:     private PreparedStatement stmt;
   7:     private ResultSet result;
   8:         ...
   9:         type = new ZeroForNullLongType();
  10:         stmt = (PreparedStatement) createMock(PreparedStatement.class);
  11:         result = (ResultSet) createMock(ResultSet.class);
  12:         ...
  13:     public void testNullSafeSetNull() throws Exception {
  14:         stmt.setLong(1, 0);

View Full Code Here
   1: import java.sql.Connection;
   2: import java.sql.PreparedStatement;
   3: import java.sql.SQLException;
   4:         ...
   5:    {
   6:       PreparedStatement ps = null;
   7:       
   8:         ...
   9:          ps = connection.prepareStatement(GET_FROM_ID);
  10:          ps.setLong(1, eventId);
  11:          ResultSet rs = ps.executeQuery();
  12:         ...
  13:    {
  14:       PreparedStatement ps = null;

View Full Code Here
   1: import java.sql.Connection;
   2: import java.sql.PreparedStatement;
   3: import java.sql.ResultSet;
   4:         ...
   5:         Connection conn = connManager.getConnection(CONNECTION_POOL);
   6:         PreparedStatement stm = null;
   7:         try {
   8:         ...
   9:             stm = conn.prepareStatement(queryStr);
  10:             stm.setLong(1, ID);
  11:             stm.setString(2, details.getName().trim());
  12:         ...
  13:         Connection conn = connManager.getConnection(CONNECTION_POOL);
  14:         PreparedStatement stm = null;

View Full Code Here
   1: import java.sql.Connection;
   2: import java.sql.PreparedStatement;
   3: import java.sql.ResultSet;
   4:         ...
   5:         Connection conn = connManager.getConnection(CONNECTION_POOL);
   6:         PreparedStatement stm = null;
   7:         try {
   8:         ...
   9:             stm = conn.prepareStatement(queryStr);
  10:             stm.setLong(1, ID);
  11:             stm.setString(2, details.getName().trim());
  12:         ...
  13:         Connection conn = connManager.getConnection(CONNECTION_POOL);
  14:         PreparedStatement stm = null;

View Full Code Here

setNull

public void setNull(int parameterIndex,
                    int sqlType)
            throws SQLException
Sets the designated parameter to SQL NULL.

Note: You must specify the parameter's SQL type.

Parameters:
parameterIndex - the first parameter is 1, the second is 2, ...
sqlType - the SQL type code defined in java.sql.Types
Throws:
SQLException - if a database access error occurs
Usages and Demos :

View More Examples of setNull(int parameterIndex,int sqlType)
   1: 
   2: import java.sql.PreparedStatement;
   3: import java.sql.ResultSet;
   4:         ...
   5:     private EnumType type;
   6:     private PreparedStatement stmt;
   7:     private ResultSet result;
   8:         ...
   9:         type = new EnumType(TestValuedEnum.ONE);
  10:         stmt = (PreparedStatement)createMock(PreparedStatement.class);
  11:         result = (ResultSet)createMock(ResultSet.class);
  12:         ...
  13:     public void testNullSafeSetNull() throws Exception {
  14:         stmt.setNull(1, Types.VARCHAR);

View Full Code Here
   1: 
   2: import java.sql.PreparedStatement;
   3: import java.sql.ResultSet;
   4:         ...
   5:     private EnumType type;
   6:     private PreparedStatement stmt;
   7:     private ResultSet result;
   8:         ...
   9:         type = new EnumType(TestValuedEnum.ONE);
  10:         stmt = (PreparedStatement) createMock(PreparedStatement.class);
  11:         result = (ResultSet) createMock(ResultSet.class);
  12:         ...
  13:     public void testNullSafeSetNull() throws Exception {
  14:         stmt.setNull(1, Types.VARCHAR);

View Full Code Here
   1: 
   2: import java.sql.PreparedStatement;
   3: import java.sql.ResultSet;
   4:         ...
   5:     private ValuedEnumType type;
   6:     private PreparedStatement stmt;
   7:     private ResultSet result;
   8:         ...
   9:         type = new ValuedEnumType(TestValuedEnum.ONE);
  10:         stmt = (PreparedStatement)createMock(PreparedStatement.class);
  11:         result = (ResultSet)createMock(ResultSet.class);
  12:         ...
  13:     public void testNullSafeSetNull() throws Exception {
  14:         stmt.setNull(1, Types.INTEGER);

View Full Code Here
   1: 
   2: import java.sql.PreparedStatement;
   3: import java.sql.ResultSet;
   4:         ...
   5:     private ValuedEnumType type;
   6:     private PreparedStatement stmt;
   7:     private ResultSet result;
   8:         ...
   9:         type = new ValuedEnumType(TestValuedEnum.ONE);
  10:         stmt = (PreparedStatement) createMock(PreparedStatement.class);
  11:         result = (ResultSet) createMock(ResultSet.class);
  12:         ...
  13:     public void testNullSafeSetNull() throws Exception {
  14:         stmt.setNull(1, Types.INTEGER);

View Full Code Here
   1: import java.sql.Connection;
   2: import java.sql.PreparedStatement;
   3: import java.sql.SQLException;
   4:         ...
   5:         Connection conn = null;
   6:         PreparedStatement stm = null;
   7:         UserActionForm f = null;
   8:         ...
   9:             {
  10:                 stm.setNull(1, Types.VARCHAR);
  11:             }
  12:         ...
  13:             {
  14:                 stm.setNull(6, Types.VARCHAR);

View Full Code Here

setNull

public void setNull(int paramIndex,
                    int sqlType,
                    String typeName)
            throws SQLException
Sets the designated parameter to SQL NULL. This version of the method setNull should be used for user-defined types and REF type parameters. Examples of user-defined types include: STRUCT, DISTINCT, JAVA_OBJECT, and named array types.

Note: To be portable, applications must give the SQL type code and the fully-qualified SQL type name when specifying a NULL user-defined or REF parameter. In the case of a user-defined type the name is the type name of the parameter itself. For a REF parameter, the name is the type name of the referenced type. If a JDBC driver does not need the type code or type name information, it may ignore it. Although it is intended for user-defined and Ref parameters, this method may be used to set a null parameter of any JDBC type. If the parameter does not have a user-defined or REF type, the given typeName is ignored.

Parameters:
paramIndex - the first parameter is 1, the second is 2, ...
sqlType - a value from java.sql.Types
typeName - the fully-qualified name of an SQL user-defined type; ignored if the parameter is not a user-defined type or REF
Throws:
SQLException - if a database access error occurs
Since:
1.2
Usages and Demos :

View More Examples of setNull(int paramIndex,int sqlType,String typeName)
   1: import java.sql.Date;
   2: import java.sql.PreparedStatement;
   3: import java.sql.Ref;
   4:         ...
   5: 
   6: abstract class C3P0PreparedStatement extends C3P0Statement implements PreparedStatement
   7: {
   8:         ...
   9:     final PreparedStatement inner;
  10: 
  11:         ...
  12:     {
  13:         inner.setNull(a, b, c);

View Full Code Here
   1: import java.sql.Date;
   2: import java.sql.PreparedStatement;
   3: import java.sql.Ref;
   4:         ...
   5: 
   6: abstract class C3P0PreparedStatement extends C3P0Statement implements PreparedStatement
   7: {
   8:         ...
   9:     final PreparedStatement inner;
  10: 
  11:         ...
  12:     {
  13:         inner.setNull(a, b, c);

View Full Code Here
   1: public class PreparedStatementAdapter extends StatementAdapter
   2:         implements PreparedStatement
   3:  {
   4:         ...
   5: 
   6:     protected PreparedStatement pstmt;
   7: 
   8:         ...
   9:     public PreparedStatementAdapter(PreparedStatement pstmt) {
  10:         super(pstmt);
  11:         ...
  12:     {
  13:         pstmt.setNull(paramIndex, sqlType, typeName);

View Full Code Here
   1: 
   2: import java.sql.PreparedStatement;
   3: import java.sql.SQLException;
   4:         ...
   5:     private MockControl psControl;
   6:     private PreparedStatement ps;
   7: 
   8:         ...
   9:     protected void setUp() {
  10:         psControl = MockControl.createControl(PreparedStatement.class);
  11:         ps = (PreparedStatement) psControl.getMock();
  12:         ...
  13:     public void testSetParameterValueWithNullAndTypeName() throws SQLException {
  14:         ps.setNull(1, Types.VARCHAR, "mytype");

View Full Code Here
   1: import java.math.BigDecimal;
   2: import java.sql.PreparedStatement;
   3: import java.sql.SQLException;
   4:         ...
   5:     public static void setParameterValue(
   6:         PreparedStatement ps, int paramIndex, SqlParameter declaredParam, Object inValue)
   7:         throws SQLException {
   8:         ...
   9:     public static void setParameterValue(
  10:         PreparedStatement ps, int paramIndex, int sqlType, String typeName, Object inValue)
  11:         throws SQLException {
  12:         ...
  13:             else if (typeName != null) {
  14:                 ps.setNull(paramIndex, sqlType, typeName);

View Full Code Here

setObject

public void setObject(int parameterIndex,
                      Object x)
            throws SQLException
Sets the value of the designated parameter using the given object. The second parameter must be of type Object; therefore, the java.lang equivalent objects should be used for built-in types.

The JDBC specification specifies a standard mapping from Java Object types to SQL types. The given argument will be converted to the corresponding SQL type before being sent to the database.

Note that this method may be used to pass datatabase- specific abstract data types, by using a driver-specific Java type. If the object is of a class implementing the interface SQLData, the JDBC driver should call the method SQLData.writeSQL to write it to the SQL data stream. If, on the other hand, the object is of a class implementing Ref, Blob, Clob, Struct, or Array, the driver should pass it to the database as a value of the corresponding SQL type.

This method throws an exception if there is an ambiguity, for example, if the object is of a class implementing more than one of the interfaces named above.

Parameters:
parameterIndex - the first parameter is 1, the second is 2, ...
x - the object containing the input parameter value
Throws:
SQLException - if a database access error occurs or the type of the given object is ambiguous
Usages and Demos :

View More Examples of setObject(int parameterIndex,Object x)
   1: 
   2:         PreparedStatement insertStatement =
   3:             connection.prepareStatement(
   4:         ...
   5:         Connection connection = getConnection();
   6:         PreparedStatement findExpensiveCoffeeStatement =
   7:             connection.prepareStatement(
   8:         ...
   9:         Connection connection = getConnection();
  10:         PreparedStatement findAllCoffeeStatement =
  11:             connection.prepareStatement("select * from catalog.beans");
  12:         ...
  13:         insertStatement.clearParameters();
  14:         insertStatement.setObject(1, productId);

View Full Code Here
   1: import java.sql.SQLException;
   2: import java.sql.PreparedStatement;
   3: import java.sql.ResultSet;
   4:         ...
   5:   {
   6:     PreparedStatement pstmt = null;
   7:     STRUCT itemSTRUCT = (STRUCT) itemStruct;
   8:         ...
   9:         " where it.id = ?" );
  10:       pstmt.setObject(1, itemObject );
  11:       pstmt.setInt(2, itemID );
  12:         ...
  13:   {
  14:     PreparedStatement pstmt = null;

View Full Code Here
   1:         Connection conn = null;
   2:         PreparedStatement pstmt = null;
   3:         ...
   4:         PreparedStatement pstmt2 = null;
   5:         try {
   6:         ...
   7: 
   8:             pstmt.setObject(1, inputValues[0]);
   9:         ...
  10:             pstmt.setObject(2, inputValues[1]);

View Full Code Here
   1: import java.sql.Connection;
   2: import java.sql.PreparedStatement;
   3: import java.sql.ResultSet;
   4:         ...
   5:     
   6:     private PreparedStatement updateStmt;
   7:         ...
   8:     private PreparedStatement insertStmt;
   9:     private PreparedStatement selectStmt;
  10:         ...
  11:         try {
  12:             updateStmt.setObject(1, o);

View Full Code Here
   1: import java.sql.SQLException;
   2: import java.sql.PreparedStatement;
   3: 
   4:         ...
   5:             Connection connection = null;
   6:             PreparedStatement statement = null;
   7:             int result = 0;
   8:         ...
   9:                 statement = connection.prepareStatement(command);
  10:                 statement.setObject(1, id);
  11:         ...
  12:                 statement.setObject(2, date);

View Full Code Here

setObject

public void setObject(int parameterIndex,
                      Object x,
                      int targetSqlType)
            throws SQLException
Sets the value of the designated parameter with the given object. This method is like the method setObject above, except that it assumes a scale of zero.
Parameters:
parameterIndex - the first parameter is 1, the second is 2, ...
x - the object containing the input parameter value
targetSqlType - the SQL type (as defined in java.sql.Types) to be sent to the database
Throws:
SQLException - if a database access error occurs
Usages and Demos :

View More Examples of setObject(int parameterIndex,Object x,int targetSqlType)
   1: import java.sql.SQLException;
   2: import java.sql.PreparedStatement;
   3: import java.sql.CallableStatement;
   4:         ...
   5:   {
   6:     PreparedStatement pstmt = null;
   7:     try
   8:         ...
   9:       pstmt = conn.prepareStatement( "insert into item_table values( ? )");
  10:       pstmt.setObject(1, itemObject, Types.STRUCT );
  11:       int numOfRowsInserted = pstmt.executeUpdate();
  12:         ...
  13:       cstmt = conn.prepareCall( "{call item_pkg.insert_item(?)}");
  14:       cstmt.setObject(1, itemObject, Types.STRUCT );

View Full Code Here
   1: import java.sql.Date;
   2: import java.sql.PreparedStatement;
   3: import java.sql.Ref;
   4:         ...
   5: 
   6: abstract class C3P0PreparedStatement extends C3P0Statement implements PreparedStatement
   7: {
   8:         ...
   9:     final PreparedStatement inner;
  10: 
  11:         ...
  12:     {
  13:         inner.setObject(a, b, c);

View Full Code Here
   1: import java.sql.Date;
   2: import java.sql.PreparedStatement;
   3: import java.sql.Ref;
   4:         ...
   5: 
   6: abstract class C3P0PreparedStatement extends C3P0Statement implements PreparedStatement
   7: {
   8:         ...
   9:     final PreparedStatement inner;
  10: 
  11:         ...
  12:     {
  13:         inner.setObject(a, b, c);

View Full Code Here
   1: 
   2: import java.sql.PreparedStatement;
   3: import java.sql.SQLException;
   4:         ...
   5:     private MockControl psControl;
   6:     private PreparedStatement ps;
   7: 
   8:         ...
   9:     protected void setUp() {
  10:         psControl = MockControl.createControl(PreparedStatement.class);
  11:         ps = (PreparedStatement) psControl.getMock();
  12:         ...
  13:     public void testSetParameterValueWithStringAndSpecialType() throws SQLException {
  14:         ps.setObject(1, "test", Types.CHAR);

View Full Code Here
   1: import java.sql.Timestamp;
   2: import java.sql.PreparedStatement;
   3: import java.sql.ResultSet;
   4:         ...
   5:     public void insert() throws SQLException {
   6:         PreparedStatement ps;
   7:         String key = "insert()#table=" + getTableName();
   8:         ...
   9:             int type = getDtype(cname);
  10:             ps.setObject(i + 1, value, type); 
  11:         }
  12:         ...
  13:     public void delete() throws SQLException {
  14:         PreparedStatement ps;

View Full Code Here

setObject

public void setObject(int parameterIndex,
                      Object x,
                      int targetSqlType,
                      int scale)
            throws SQLException
Sets the value of the designated parameter with the given object. The second argument must be an object type; for integral values, the java.lang equivalent objects should be used.

The given Java object will be converted to the given targetSqlType before being sent to the database. If the object has a custom mapping (is of a class implementing the interface SQLData), the JDBC driver should call the method SQLData.writeSQL to write it to the SQL data stream. If, on the other hand, the object is of a class implementing Ref, Blob, Clob, Struct, or Array, the driver should pass it to the database as a value of the corresponding SQL type.

Note that this method may be used to pass database-specific abstract data types.

Parameters:
parameterIndex - the first parameter is 1, the second is 2, ...
x - the object containing the input parameter value
targetSqlType - the SQL type (as defined in java.sql.Types) to be sent to the database. The scale argument may further qualify this type.
scale - for java.sql.Types.DECIMAL or java.sql.Types.NUMERIC types, this is the number of digits after the decimal point. For all other types, this value will be ignored.
Throws:
SQLException - if a database access error occurs
See Also:
Types
Usages and Demos :

View More Examples of setObject(int parameterIndex,Object x,int targetSqlType,int scale)
   1: import java.sql.Date;
   2: import java.sql.PreparedStatement;
   3: import java.sql.Ref;
   4:         ...
   5: 
   6: abstract class C3P0PreparedStatement extends C3P0Statement implements PreparedStatement
   7: {
   8:         ...
   9:     final PreparedStatement inner;
  10: 
  11:         ...
  12:     {
  13:         inner.setObject(a, b, c, d);

View Full Code Here
   1: import java.sql.Date;
   2: import java.sql.PreparedStatement;
   3: import java.sql.Ref;
   4:         ...
   5: 
   6: abstract class C3P0PreparedStatement extends C3P0Statement implements PreparedStatement
   7: {
   8:         ...
   9:     final PreparedStatement inner;
  10: 
  11:         ...
  12:     {
  13:         inner.setObject(a, b, c, d);

View Full Code Here
   1: public class PreparedStatementAdapter extends StatementAdapter
   2:         implements PreparedStatement
   3:  {
   4:         ...
   5: 
   6:     protected PreparedStatement pstmt;
   7: 
   8:         ...
   9:     public PreparedStatementAdapter(PreparedStatement pstmt) {
  10:         super(pstmt);
  11:         ...
  12:     {
  13:         pstmt.setObject(parameterIndex, x, targetSqlType, scale);

View Full Code Here
   1: import java.sql.ParameterMetaData;
   2: import java.sql.PreparedStatement;
   3: import java.sql.Ref;
   4:         ...
   5: 
   6: public abstract class FilterPreparedStatement implements PreparedStatement
   7: {
   8:         ...
   9:     protected PreparedStatement inner;
  10:     
  11:         ...
  12:     public void setObject(int a, Object b, int c, int d) throws SQLException
  13:     { inner.setObject(a, b, c, d); }

View Full Code Here
   1: import java.sql.ParameterMetaData;
   2: import java.sql.PreparedStatement;
   3: import java.sql.Ref;
   4:         ...
   5: 
   6: public abstract class SynchronizedFilterPreparedStatement implements PreparedStatement
   7: {
   8:         ...
   9:     protected PreparedStatement inner;
  10:     
  11:         ...
  12:     public synchronized void setObject(int a, Object b, int c, int d) throws SQLException
  13:     { inner.setObject(a, b, c, d); }

View Full Code Here

setRef

public void setRef(int i,
                   Ref x)
            throws SQLException
Sets the designated parameter to the given REF(<structured-type>) value. The driver converts this to an SQL REF value when it sends it to the database.
Parameters:
i - the first parameter is 1, the second is 2, ...
x - an SQL REF value
Throws:
SQLException - if a database access error occurs
Since:
1.2
Usages and Demos :

View More Examples of setRef(int i,Ref x)
   1: import java.lang.reflect.InvocationTargetException;
   2: import java.sql.PreparedStatement;
   3: import java.sql.Ref;
   4:         ...
   5: 
   6:     public void doFillStatement(PreparedStatement pst, Object value, int index) throws SQLException, IllegalAccessException, InvocationTargetException {
   7:         ...
   8:         pst.setRef(index, (Ref) value);
   9:     }

View Full Code Here
   1: import java.sql.Connection;
   2: import java.sql.PreparedStatement;
   3: import java.sql.Ref;
   4:         ...
   5:       " from emp_table_with_ref e";
   6:     PreparedStatement pstmt = null;
   7:     OracleResultSet orset = null;
   8:         ...
   9: 
  10:     PreparedStatement pstmt = null;
  11:     OracleResultSet orset = null;
  12:         ...
  13:       pstmt = conn.prepareStatement( updateStmtString  );
  14:       pstmt.setRef( 1, newManagerRef );

View Full Code Here
   1: import java.sql.Connection;
   2: import java.sql.PreparedStatement;
   3: import java.sql.Ref;
   4:         ...
   5:       " where e.emp_no = ? for update nowait";
   6:     PreparedStatement pstmt = null;
   7:     ResultSet rset = null;
   8:         ...
   9:                         " from emp_table_with_ref e";
  10:     PreparedStatement pstmt = null;
  11:     ResultSet rset = null;
  12:         ...
  13:       pstmt = conn.prepareStatement( updateStmtString  );
  14:       pstmt.setRef( 1, newManagerRef );

View Full Code Here
   1: import java.sql.Date;
   2: import java.sql.PreparedStatement;
   3: import java.sql.Ref;
   4:         ...
   5: 
   6: abstract class C3P0PreparedStatement extends C3P0Statement implements PreparedStatement
   7: {
   8:         ...
   9:     final PreparedStatement inner;
  10: 
  11:         ...
  12:     {
  13:         inner.setRef(a, b);

View Full Code Here
   1: import java.sql.Date;
   2: import java.sql.PreparedStatement;
   3: import java.sql.Ref;
   4:         ...
   5: 
   6: abstract class C3P0PreparedStatement extends C3P0Statement implements PreparedStatement
   7: {
   8:         ...
   9:     final PreparedStatement inner;
  10: 
  11:         ...
  12:     {
  13:         inner.setRef(a, b);

View Full Code Here

setShort

public void setShort(int parameterIndex,
                     short x)
            throws SQLException
Sets the designated parameter to the given Java short value. The driver converts this to an SQL SMALLINT value when it sends it to the database.
Parameters:
parameterIndex - the first parameter is 1, the second is 2, ...
x - the parameter value
Throws:
SQLException - if a database access error occurs
Usages and Demos :

View More Examples of setShort(int parameterIndex,short x)
   1:         Connection conn = null;
   2:         PreparedStatement pstmt = null;
   3:         try {
   4:         ...
   5:             pstmt.setByte(2, byteValue);
   6:             pstmt.setShort(3, shortValue);
   7:             pstmt.setInt(4, intValue);
   8:             pstmt.setLong(5, longValue);

View Full Code Here
   1: 
   2: private PreparedStatement statement = null;
   3: 
   4:         ...
   5:       statement.setString(2, area.getFieldIndex());
   6:       statement.setShort( 3, area.getCcd());
   7:       statement.setString(4, String.valueOf(area.getQuarter()));
   8: 
   9:       ResultSet result = statement.executeQuery();

View Full Code Here
   1: import java.sql.Date;
   2: import java.sql.PreparedStatement;
   3: import java.sql.Ref;
   4:         ...
   5: 
   6: abstract class C3P0PreparedStatement extends C3P0Statement implements PreparedStatement
   7: {
   8:         ...
   9:     final PreparedStatement inner;
  10: 
  11:         ...
  12:     {
  13:         inner.setShort(a, b);

View Full Code Here
   1: import java.sql.Date;
   2: import java.sql.PreparedStatement;
   3: import java.sql.Ref;
   4:         ...
   5: 
   6: abstract class C3P0PreparedStatement extends C3P0Statement implements PreparedStatement
   7: {
   8:         ...
   9:     final PreparedStatement inner;
  10: 
  11:         ...
  12:     {
  13:         inner.setShort(a, b);

View Full Code Here
   1: import java.sql.Connection;
   2: import java.sql.PreparedStatement;
   3: import java.sql.ResultSet;
   4:         ...
   5:         Connection cnn = null;
   6:         PreparedStatement pst = null;
   7:         ResultSet rs = null;
   8:         ...
   9:             pst.setInt(i++, this.maxNodeEntries);
  10:             pst.setShort(i++, this.splitAlg);

View Full Code Here

setString

public void setString(int parameterIndex,
                      String x)
            throws SQLException
Sets the designated parameter to the given Java String value. The driver converts this to an SQL VARCHAR or LONGVARCHAR value (depending on the argument's size relative to the driver's limits on VARCHAR values) when it sends it to the database.
Parameters:
parameterIndex - the first parameter is 1, the second is 2, ...
x - the parameter value
Throws:
SQLException - if a database access error occurs
Usages and Demos :

View More Examples of setString(int parameterIndex,String x)
   1: import java.sql.Connection;
   2: import java.sql.PreparedStatement;
   3: import java.sql.ResultSet;
   4:         ...
   5:   public void buildList(Connection db) throws SQLException {
   6:     PreparedStatement pst = null;
   7:     ResultSet rs;
   8:         ...
   9: 
  10:   protected int prepareFilter(PreparedStatement pst) throws SQLException {
  11:     int i = 0;
  12:         ...
  13:       if (StringUtils.hasText(searchCriteria.getFirstName())) {
  14:         pst.setString(++i, "%" + searchCriteria.getFirstName().toLowerCase() + "%");

View Full Code Here
   1: import java.sql.Connection;
   2: import java.sql.PreparedStatement;
   3: import java.sql.ResultSet;
   4:         ...
   5:         Connection connection = null;
   6:         PreparedStatement ps = null;
   7:         ResultSet rs = null;
   8:         ...
   9:                     " and " + REMOTE_JDBC_PRIMKEY_MAP + ".map_id = " + REMOTE_JDBC_PRIMKEY + ".map_id");
  10:             ps.setString(1, (String) localKey.getComponent("personId").getValue());
  11:             ps.setBigDecimal(2, (BigDecimal) localKey.getComponent("entryId").getValue());
  12:         ...
  13:         Connection connection = null;
  14:         PreparedStatement ps = null;

View Full Code Here
   1: import java.sql.Connection;
   2: import java.sql.PreparedStatement;
   3: import java.sql.SQLException;
   4:         ...
   5:   public boolean insert(Connection db) throws SQLException {
   6:     PreparedStatement pst = db.prepareStatement(
   7:         "INSERT INTO customer_order_address " +
   8:         ...
   9:     pst.setInt(++i, orderId);
  10:     pst.setString(++i, "Billing");
  11:         ...
  12:     pst.setString(++i, nameFirst);

View Full Code Here
   1:         Connection c = null;
   2:         PreparedStatement ps = null;
   3:         try
   4:         ...
   5:         Connection c = null;
   6:         PreparedStatement ps = null;
   7:         try
   8:         ...
   9:         Connection c = null;
  10:         PreparedStatement ps = null;
  11:         try
  12:         ...
  13:                 if (pObject.isStateAbbreviationModified()) {
  14:                     ps.setString(++_dirtyCount, pObject.getStateAbbreviation());

View Full Code Here
   1:         Connection c = null;
   2:         PreparedStatement ps = null;
   3:         try
   4:         ...
   5:         Connection c = null;
   6:         PreparedStatement ps = null;
   7:         try
   8:         ...
   9:         Connection c = null;
  10:         PreparedStatement ps = null;
  11:         try
  12:         ...
  13:                 if (pObject.isProductCodeModified()) {
  14:                     ps.setString(++_dirtyCount, pObject.getProductCode());

View Full Code Here

setTime

public void setTime(int parameterIndex,
                    Time x)
            throws SQLException
Sets the designated parameter to the given java.sql.Time value. The driver converts this to an SQL TIME value when it sends it to the database.
Parameters:
parameterIndex - the first parameter is 1, the second is 2, ...
x - the parameter value
Throws:
SQLException - if a database access error occurs
Usages and Demos :

View More Examples of setTime(int parameterIndex,java.sql.Time x)
   1:       Connection conn = null;
   2:       PreparedStatement pstmt = null;
   3:       try {
   4:         ...
   5:          pstmt.setDate(2, sqlDate);
   6:          pstmt.setTime(3, sqlTime);
   7:          pstmt.setTimestamp(4, sqlTimestamp);
   8:          pstmt.executeUpdate();
   9:       }

View Full Code Here
   1:         Connection conn = null;
   2:         PreparedStatement pstmt = null;
   3:         try {
   4:         ...
   5:             System.out.println("time="+time);
   6:             pstmt.setTime(2, time);
   7:             java.sql.Timestamp timestamp = getCurrentJavaSqlTimestamp();
   8:             System.out.println("timestamp="+timestamp);
   9:             pstmt.setTimestamp(3, timestamp);

View Full Code Here
   1: import java.sql.DriverManager;
   2: import java.sql.PreparedStatement;
   3: import java.sql.Time;
   4:         ...
   5:           
   6:             PreparedStatement pstmt = conn.prepareStatement("INSERT INTO timeTest VALUES (?, ?)");
   7:             
   8:         ...
   9:             pstmt.setTimestamp(1, nowTstamp);
  10:             pstmt.setTime(2, nowTime);
  11:             pstmt.executeUpdate();

View Full Code Here
   1: import java.sql.Date;
   2: import java.sql.PreparedStatement;
   3: import java.sql.Ref;
   4:         ...
   5: 
   6: abstract class C3P0PreparedStatement extends C3P0Statement implements PreparedStatement
   7: {
   8:         ...
   9:     final PreparedStatement inner;
  10: 
  11:         ...
  12:     {
  13:         inner.setTime(a, b);

View Full Code Here
   1: import java.sql.Date;
   2: import java.sql.PreparedStatement;
   3: import java.sql.Ref;
   4:         ...
   5: 
   6: abstract class C3P0PreparedStatement extends C3P0Statement implements PreparedStatement
   7: {
   8:         ...
   9:     final PreparedStatement inner;
  10: 
  11:         ...
  12:     {
  13:         inner.setTime(a, b);

View Full Code Here

setTime

public void setTime(int parameterIndex,
                    Time x,
                    Calendar cal)
            throws SQLException
Sets the designated parameter to the given java.sql.Time value, using the given Calendar object. The driver uses the Calendar object to construct an SQL TIME value, which the driver then sends to the database. With a Calendar object, the driver can calculate the time taking into account a custom timezone. If no Calendar object is specified, the driver uses the default timezone, which is that of the virtual machine running the application.
Parameters:
parameterIndex - the first parameter is 1, the second is 2, ...
x - the parameter value
cal - the Calendar object the driver will use to construct the time
Throws:
SQLException - if a database access error occurs
Since:
1.2
Usages and Demos :

View More Examples of setTime(int parameterIndex,java.sql.Time x,Calendar cal)
   1: import java.sql.Date;
   2: import java.sql.PreparedStatement;
   3: import java.sql.Ref;
   4:         ...
   5: 
   6: abstract class C3P0PreparedStatement extends C3P0Statement implements PreparedStatement
   7: {
   8:         ...
   9:     final PreparedStatement inner;
  10: 
  11:         ...
  12:     {
  13:         inner.setTime(a, b, c);

View Full Code Here
   1: import java.sql.Date;
   2: import java.sql.PreparedStatement;
   3: import java.sql.Ref;
   4:         ...
   5: 
   6: abstract class C3P0PreparedStatement extends C3P0Statement implements PreparedStatement
   7: {
   8:         ...
   9:     final PreparedStatement inner;
  10: 
  11:         ...
  12:     {
  13:         inner.setTime(a, b, c);

View Full Code Here
   1: public class PreparedStatementAdapter extends StatementAdapter
   2:         implements PreparedStatement
   3:  {
   4:         ...
   5: 
   6:     protected PreparedStatement pstmt;
   7: 
   8:         ...
   9:     public PreparedStatementAdapter(PreparedStatement pstmt) {
  10:         super(pstmt);
  11:         ...
  12:     {
  13:         pstmt.setTime(parameterIndex, x, cal);

View Full Code Here
   1: import java.sql.ParameterMetaData;
   2: import java.sql.PreparedStatement;
   3: import java.sql.Ref;
   4:         ...
   5: 
   6: public abstract class FilterPreparedStatement implements PreparedStatement
   7: {
   8:         ...
   9:     protected PreparedStatement inner;
  10:     
  11:         ...
  12:     public void setTime(int a, Time b, Calendar c) throws SQLException
  13:     { inner.setTime(a, b, c); }

View Full Code Here
   1: import java.sql.ParameterMetaData;
   2: import java.sql.PreparedStatement;
   3: import java.sql.Ref;
   4:         ...
   5: 
   6: public abstract class SynchronizedFilterPreparedStatement implements PreparedStatement
   7: {
   8:         ...
   9:     protected PreparedStatement inner;
  10:     
  11:         ...
  12:     public synchronized void setTime(int a, Time b, Calendar c) throws SQLException
  13:     { inner.setTime(a, b, c); }

View Full Code Here

setTimestamp

public void setTimestamp(int parameterIndex,
                         Timestamp x)
            throws SQLException
Sets the designated parameter to the given java.sql.Timestamp value. The driver converts this to an SQL TIMESTAMP value when it sends it to the database.
Parameters:
parameterIndex - the first parameter is 1, the second is 2, ...
x - the parameter value
Throws:
SQLException - if a database access error occurs
Usages and Demos :

View More Examples of setTimestamp(int parameterIndex,java.sql.Timestamp x)
   1: import java.sql.Connection;
   2: import java.sql.PreparedStatement;
   3: import java.sql.ResultSet;
   4:         ...
   5:   public void buildList(Connection db) throws SQLException {
   6:     PreparedStatement pst = null;
   7:     ResultSet rs = null;
   8:         ...
   9: 
  10:   protected int prepareFilter(PreparedStatement pst) throws SQLException {
  11:     int i = 0;
  12:         ...
  13:     if (alertRangeStart != null) {
  14:       pst.setTimestamp(++i, alertRangeStart);

View Full Code Here
   1:   public TicketContact(Connection db, int ticketContactId) throws SQLException {
   2:     PreparedStatement pst = db.prepareStatement(
   3:         "SELECT tc.* " +
   4:         ...
   5:   public boolean insert(Connection db) throws SQLException {
   6:     PreparedStatement pst = db.prepareStatement(
   7:         "INSERT INTO ticket_contacts (ticketid, user_id, contact_id, contact_name, contact_email," +
   8:         ...
   9:     if (entered != null) {
  10:       pst.setTimestamp(++i, entered);
  11:     }
  12:         ...
  13:   public void delete(Connection db) throws SQLException {
  14:     PreparedStatement pst = db.prepareStatement(

View Full Code Here
   1:     }
   2:     PreparedStatement pst = db.prepareStatement(
   3:         "SELECT item_id, version, user_download_id, download_date " +
   4:         ...
   5:   public boolean insert(Connection db) throws SQLException {
   6:     PreparedStatement pst = db.prepareStatement(
   7:         "INSERT INTO project_files_download " +
   8:         ...
   9:     pst.setInt(++i, userId);
  10:     pst.setTimestamp(++i, downloadDate);
  11:     pst.execute();
  12:         ...
  13:     }
  14:     PreparedStatement pst = db.prepareStatement(

View Full Code Here
   1:     }
   2:     PreparedStatement pst = db.prepareStatement(sql.toString());
   3:     int i = 0;
   4:         ...
   5:       int i = 0;
   6:       PreparedStatement pst = db.prepareStatement(sql.toString());
   7:       pst.setInt(++i, wikiId);
   8:         ...
   9:       if (entered != null) {
  10:         pst.setTimestamp(++i, entered);
  11:       }
  12:         ...
  13:       if (modified != null) {
  14:         pst.setTimestamp(++i, entered);

View Full Code Here
   1: import java.sql.Connection;
   2: import java.sql.PreparedStatement;
   3: import java.sql.SQLException;
   4:         ...
   5:   public boolean insert(Connection db) throws SQLException {
   6:     PreparedStatement pst = db.prepareStatement(
   7:         "INSERT INTO project_files_thumbnail " +
   8:         ...
   9:     if (entered != null) {
  10:       pst.setTimestamp(++i, entered);
  11:     }
  12:         ...
  13:     if (modified != null) {
  14:       pst.setTimestamp(++i, modified);

View Full Code Here

setTimestamp

public void setTimestamp(int parameterIndex,
                         Timestamp x,
                         Calendar cal)
            throws SQLException
Sets the designated parameter to the given java.sql.Timestamp value, using the given Calendar object. The driver uses the Calendar object to construct an SQL TIMESTAMP value, which the driver then sends to the database. With a Calendar object, the driver can calculate the timestamp taking into account a custom timezone. If no Calendar object is specified, the driver uses the default timezone, which is that of the virtual machine running the application.
Parameters:
parameterIndex - the first parameter is 1, the second is 2, ...
x - the parameter value
cal - the Calendar object the driver will use to construct the timestamp
Throws:
SQLException - if a database access error occurs
Since:
1.2
Usages and Demos :

View More Examples of setTimestamp(int parameterIndex,java.sql.Timestamp x,Calendar cal)
   1:         stat=conn.createStatement();
   2:         PreparedStatement prep;
   3:         ResultSet rs;
   4:         ...
   5:         prep.setInt(1,1);
   6:         prep.setTimestamp(2,t0,local);
   7:         prep.setBigDecimal(3,n1);
   8:         ...
   9:         prep.setInt(1,2);
  10:         prep.setTimestamp(2,t0,gmt);
  11:         prep.setBigDecimal(3,n0);
  12:         ...
  13:         prep.setInt(1,3);
  14:         prep.setTimestamp(2,t0,plusone);

View Full Code Here
   1: import java.sql.Date;
   2: import java.sql.PreparedStatement;
   3: import java.sql.Ref;
   4:         ...
   5: 
   6: abstract class C3P0PreparedStatement extends C3P0Statement implements PreparedStatement
   7: {
   8:         ...
   9:     final PreparedStatement inner;
  10: 
  11:         ...
  12:     {
  13:         inner.setTimestamp(a, b, c);

View Full Code Here
   1: import java.sql.Date;
   2: import java.sql.PreparedStatement;
   3: import java.sql.Ref;
   4:         ...
   5: 
   6: abstract class C3P0PreparedStatement extends C3P0Statement implements PreparedStatement
   7: {
   8:         ...
   9:     final PreparedStatement inner;
  10: 
  11:         ...
  12:     {
  13:         inner.setTimestamp(a, b, c);

View Full Code Here
   1: public class PreparedStatementAdapter extends StatementAdapter
   2:         implements PreparedStatement
   3:  {
   4:         ...
   5: 
   6:     protected PreparedStatement pstmt;
   7: 
   8:         ...
   9:     public PreparedStatementAdapter(PreparedStatement pstmt) {
  10:         super(pstmt);
  11:         ...
  12:     {
  13:         pstmt.setTimestamp(parameterIndex, x, cal);

View Full Code Here
   1: import java.sql.DriverManager;
   2: import java.sql.PreparedStatement;
   3: import java.sql.ResultSet;
   4:         ...
   5:                 s.execute("CREATE TABLE DATETEST (DATEID INTEGER NOT NULL PRIMARY KEY, TESTDATE TIMESTAMP)");
   6:                 PreparedStatement ps = c.prepareStatement("INSERT INTO DATETEST (DATEID, TESTDATE) VALUES (?,?)");
   7:                 Calendar cal = new GregorianCalendar(timeZoneUTC);
   8:         ...
   9:                     ps.setInt(1, 1);
  10:                     ps.setTimestamp(2, x, cal);
  11:                     ps.execute();

View Full Code Here

setURL

public void setURL(int parameterIndex,
                   URL x)
            throws SQLException
Sets the designated parameter to the given java.net.URL value. The driver converts this to an SQL DATALINK value when it sends it to the database.
Parameters:
parameterIndex - the first parameter is 1, the second is 2, ...
x - the java.net.URL object to be set
Throws:
SQLException - if a database access error occurs
Since:
1.4
Usages and Demos :

View More Examples of setURL(int parameterIndex,java.net.URL x)
   1: import java.net.URL;
   2: import java.sql.PreparedStatement;
   3: import java.sql.ResultSet;
   4:         ...
   5: 
   6:     public void doFillStatement(PreparedStatement pst, Object value, int index) throws SQLException, IllegalAccessException, InvocationTargetException {
   7:         ...
   8:         pst.setURL(index, (URL) value);
   9:     }

View Full Code Here
   1: public class PreparedStatementAdapter extends StatementAdapter
   2:         implements PreparedStatement
   3:  {
   4:         ...
   5: 
   6:     protected PreparedStatement pstmt;
   7: 
   8:         ...
   9:     public PreparedStatementAdapter(PreparedStatement pstmt) {
  10:         super(pstmt);
  11:         ...
  12:     public void setURL(int parameterIndex, URL x)  throws SQLException {
  13:         pstmt.setURL(parameterIndex,x);

View Full Code Here
   1: import java.sql.ParameterMetaData;
   2: import java.sql.PreparedStatement;
   3: import java.sql.Ref;
   4:         ...
   5: 
   6: public abstract class FilterPreparedStatement implements PreparedStatement
   7: {
   8:         ...
   9:     protected PreparedStatement inner;
  10:     
  11:         ...
  12:     public void setURL(int a, URL b) throws SQLException
  13:     { inner.setURL(a, b); }

View Full Code Here
   1: import java.sql.ParameterMetaData;
   2: import java.sql.PreparedStatement;
   3: import java.sql.Ref;
   4:         ...
   5: 
   6: public abstract class SynchronizedFilterPreparedStatement implements PreparedStatement
   7: {
   8:         ...
   9:     protected PreparedStatement inner;
  10:     
  11:         ...
  12:     public synchronized void setURL(int a, URL b) throws SQLException
  13:     { inner.setURL(a, b); }

View Full Code Here
   1: import java.sql.ParameterMetaData;
   2: import java.sql.PreparedStatement;
   3: import java.sql.Ref;
   4:         ...
   5:     
   6:     private PreparedStatement stmt;
   7:     private ResultSet rs;
   8:         ...
   9:     public void setURL(int i, java.net.URL x) throws SQLException {
  10:         stmt.setURL(i, x);
  11:     }

View Full Code Here

void setUnicodeStream

public @Deprecated void setUnicodeStream(int parameterIndex,
                                         InputStream x,
                                         int length)
            throws SQLException

Deprecated.

Sets the designated parameter to the given input stream, which will have the specified number of bytes. A Unicode character has two bytes, with the first byte being the high byte, and the second being the low byte. When a very large Unicode value is input to a LONGVARCHAR parameter, it may be more practical to send it via a java.io.InputStream object. The data will be read from the stream as needed until end-of-file is reached. The JDBC driver will do any necessary conversion from Unicode to the database char format.

Note: This stream object can either be a standard Java stream object or your own subclass that implements the standard interface.

Parameters:
parameterIndex - the first parameter is 1, the second is 2, ...
x - a java.io.InputStream object that contains the Unicode parameter value as two-byte Unicode characters
length - the number of bytes in the stream
Throws:
SQLException - if a database access error occurs