|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object cluster5.server.datastorage.NamedParameterStatement
public class NamedParameterStatement
http://www.java2s.com/Article/Java/Database-JDBC/Named_Parameters_for_PreparedStatement .htm
Constructor Summary | |
---|---|
NamedParameterStatement(java.sql.Connection connection,
java.lang.String query)
Creates a NamedParameterStatement. |
Method Summary | |
---|---|
void |
addBatch()
Adds the current set of parameters as a batch entry. |
void |
close()
Closes the statement. |
boolean |
execute()
Executes the statement. |
int[] |
executeBatch()
Executes all of the batched statements. |
java.sql.ResultSet |
executeQuery()
Executes the statement, which must be a query. |
int |
executeUpdate()
Executes the statement, which must be an SQL INSERT, UPDATE or DELETE statement; or an SQL statement that returns nothing, such as a DDL statement. |
java.sql.PreparedStatement |
getStatement()
Returns the underlying statement. |
void |
setBoolean(java.lang.String name,
boolean value)
Sets a parameter. |
void |
setBytes(java.lang.String name,
byte[] value)
Sets a parameter. |
void |
setDate(java.lang.String name,
java.util.Date date)
Sets a parameter. |
void |
setInt(java.lang.String name,
int value)
Sets a parameter. |
void |
setLong(java.lang.String name,
java.lang.Long value)
Sets a parameter. |
void |
setObject(java.lang.String name,
java.lang.Object value)
Sets a parameter. |
void |
setString(java.lang.String name,
java.lang.String value)
Sets a parameter. |
void |
setTimestamp(java.lang.String name,
java.sql.Timestamp value)
Sets a parameter. |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public NamedParameterStatement(java.sql.Connection connection, java.lang.String query) throws java.sql.SQLException
prepareStatement
.
connection
- the database connectionquery
- the parameterized query
java.sql.SQLException
- if the statement could not be createdMethod Detail |
---|
public void setObject(java.lang.String name, java.lang.Object value) throws java.sql.SQLException
name
- parameter namevalue
- parameter value
java.sql.SQLException
- if an error occurred
java.lang.IllegalArgumentException
- if the parameter does not existPreparedStatement.setObject(int, java.lang.Object)
public void setString(java.lang.String name, java.lang.String value) throws java.sql.SQLException
name
- parameter namevalue
- parameter value
java.sql.SQLException
- if an error occurred
java.lang.IllegalArgumentException
- if the parameter does not existPreparedStatement.setString(int, java.lang.String)
public void setDate(java.lang.String name, java.util.Date date) throws java.sql.SQLException
name
- date
-
java.sql.SQLException
public void setInt(java.lang.String name, int value) throws java.sql.SQLException
name
- parameter namevalue
- parameter value
java.sql.SQLException
- if an error occurred
java.lang.IllegalArgumentException
- if the parameter does not existPreparedStatement.setInt(int, int)
public void setLong(java.lang.String name, java.lang.Long value) throws java.sql.SQLException
name
- parameter namevalue
- parameter value
java.sql.SQLException
- if an error occurred
java.lang.IllegalArgumentException
- if the parameter does not existPreparedStatement.setInt(int, int)
public void setTimestamp(java.lang.String name, java.sql.Timestamp value) throws java.sql.SQLException
name
- parameter namevalue
- parameter value
java.sql.SQLException
- if an error occurred
java.lang.IllegalArgumentException
- if the parameter does not existPreparedStatement.setTimestamp(int, java.sql.Timestamp)
public void setBoolean(java.lang.String name, boolean value) throws java.sql.SQLException
name
- parameter namevalue
- parameter value
java.sql.SQLException
- if an error occurred
java.lang.IllegalArgumentException
- if the parameter does not existPreparedStatement.setInt(int, int)
public void setBytes(java.lang.String name, byte[] value) throws java.sql.SQLException
name
- parameter namevalue
- parameter value
java.sql.SQLException
- if an error occurred
java.lang.IllegalArgumentException
- if the parameter does not existPreparedStatement.setInt(int, int)
public java.sql.PreparedStatement getStatement()
public boolean execute() throws java.sql.SQLException
ResultSet
java.sql.SQLException
- if an error occurredPreparedStatement.execute()
public java.sql.ResultSet executeQuery() throws java.sql.SQLException
java.sql.SQLException
- if an error occurredPreparedStatement.executeQuery()
public int executeUpdate() throws java.sql.SQLException
java.sql.SQLException
- if an error occurredPreparedStatement.executeUpdate()
public void close() throws java.sql.SQLException
java.sql.SQLException
- if an error occurredStatement.close()
public void addBatch() throws java.sql.SQLException
java.sql.SQLException
- if something went wrongpublic int[] executeBatch() throws java.sql.SQLException
Statement.executeBatch()
for details.
java.sql.SQLException
- if something went wrong
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |