本文整理汇总了Java中java.sql.PreparedStatement.setBigDecimal方法的典型用法代码示例。如果您正苦于以下问题:Java PreparedStatement.setBigDecimal方法的具体用法?Java PreparedStatement.setBigDecimal怎么用?Java PreparedStatement.setBigDecimal使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.sql.PreparedStatement
的用法示例。
在下文中一共展示了PreparedStatement.setBigDecimal方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: updateExtendedTriggerProperties
import java.sql.PreparedStatement; //导入方法依赖的package包/类
public int updateExtendedTriggerProperties(Connection conn, OperableTrigger trigger, String state, JobDetail jobDetail) throws SQLException, IOException {
SimpleTrigger simpleTrigger = (SimpleTrigger)trigger;
PreparedStatement ps = null;
try {
ps = conn.prepareStatement(Util.rtp(UPDATE_SIMPLE_TRIGGER, tablePrefix, schedNameLiteral));
ps.setInt(1, simpleTrigger.getRepeatCount());
ps.setBigDecimal(2, new BigDecimal(String.valueOf(simpleTrigger.getRepeatInterval())));
ps.setInt(3, simpleTrigger.getTimesTriggered());
ps.setString(4, simpleTrigger.getKey().getName());
ps.setString(5, simpleTrigger.getKey().getGroup());
return ps.executeUpdate();
} finally {
Util.closeStatement(ps);
}
}
示例2: createHolding
import java.sql.PreparedStatement; //导入方法依赖的package包/类
private HoldingDataBean createHolding(Connection conn, int accountID,
String symbol, double quantity, BigDecimal purchasePrice)
throws Exception {
HoldingDataBean holdingData = null;
Timestamp purchaseDate = new Timestamp(System.currentTimeMillis());
PreparedStatement stmt = getStatement(conn, createHoldingSQL);
Integer holdingID = KeySequenceDirect.getNextID(conn, "holding",
inSession, getInGlobalTxn());
stmt.setInt(1, holdingID.intValue());
stmt.setTimestamp(2, purchaseDate);
stmt.setBigDecimal(3, purchasePrice);
stmt.setDouble(4, quantity);
stmt.setString(5, symbol);
stmt.setInt(6, accountID);
int rowCount = stmt.executeUpdate();
stmt.close();
return getHoldingData(conn, holdingID.intValue());
}
示例3: PreparedStmtSetValue
import java.sql.PreparedStatement; //导入方法依赖的package包/类
private void PreparedStmtSetValue(PreparedStatement pStmt, int idx, Object obj) throws SQLException{
if (obj instanceof String) {
pStmt.setString(idx, (String) obj);
} else if(obj instanceof Integer){
pStmt.setInt(idx, (Integer) obj);
} else if(obj instanceof BigDecimal){
pStmt.setBigDecimal(idx, (BigDecimal) obj);
} else if(obj instanceof Double){
pStmt.setDouble(idx, (Double) obj);
} else if(obj instanceof Date){
pStmt.setDate(idx, (Date) obj);
} else if(obj instanceof byte[]){
pStmt.setBytes(idx, (byte[]) obj);
} else{
pStmt.setObject(idx, obj);
}
}
示例4: transfer
import java.sql.PreparedStatement; //导入方法依赖的package包/类
public boolean transfer(int nColumnNumber1Based, ResultSet resultSetSource, PreparedStatement insertStatementInsert)
{
try
{
BigDecimal value = resultSetSource.getBigDecimal(m_nColSourceIndex);
if (!resultSetSource.wasNull())
insertStatementInsert.setBigDecimal(m_nColSourceIndex, value);
else
insertStatementInsert.setNull(m_nColSourceIndex, Types.DECIMAL);
return true;
}
catch (SQLException e)
{
e.printStackTrace();
}
return false;
}
示例5: countMisfiredTriggersInState
import java.sql.PreparedStatement; //导入方法依赖的package包/类
/**
* <p>
* Get the number of triggers in the given states that have
* misfired - according to the given timestamp.
* </p>
*
* @param conn the DB Connection
*/
public int countMisfiredTriggersInState(
Connection conn, String state1, long ts) throws SQLException {
PreparedStatement ps = null;
ResultSet rs = null;
try {
ps = conn.prepareStatement(rtp(COUNT_MISFIRED_TRIGGERS_IN_STATE));
ps.setBigDecimal(1, new BigDecimal(String.valueOf(ts)));
ps.setString(2, state1);
rs = ps.executeQuery();
if (rs.next()) {
return rs.getInt(1);
}
throw new SQLException("No misfired trigger count returned.");
} finally {
closeResultSet(rs);
closeStatement(ps);
}
}
示例6: selectMisfiredTriggersInGroupInState
import java.sql.PreparedStatement; //导入方法依赖的package包/类
/**
* <p>
* Get the names of all of the triggers in the given group and state that
* have misfired.
* </p>
*
* @param conn
* the DB Connection
* @return an array of <code>{@link
* org.quartz.utils.Key}</code> objects
*/
public List<TriggerKey> selectMisfiredTriggersInGroupInState(Connection conn,
String groupName, String state, long ts) throws SQLException {
PreparedStatement ps = null;
ResultSet rs = null;
try {
ps = conn
.prepareStatement(rtp(SELECT_MISFIRED_TRIGGERS_IN_GROUP_IN_STATE));
ps.setBigDecimal(1, new BigDecimal(String.valueOf(ts)));
ps.setString(2, groupName);
ps.setString(3, state);
rs = ps.executeQuery();
LinkedList<TriggerKey> list = new LinkedList<TriggerKey>();
while (rs.next()) {
String triggerName = rs.getString(COL_TRIGGER_NAME);
list.add(triggerKey(triggerName, groupName));
}
return list;
} finally {
closeResultSet(rs);
closeStatement(ps);
}
}
示例7: insertSimpleTrigger
import java.sql.PreparedStatement; //导入方法依赖的package包/类
/**
* <p>
* Insert the simple trigger data.
* </p>
*
* @param conn
* the DB Connection
* @param trigger
* the trigger to insert
* @return the number of rows inserted
*/
public int insertSimpleTrigger(Connection conn, SimpleTrigger trigger)
throws SQLException {
PreparedStatement ps = null;
try {
ps = conn.prepareStatement(rtp(INSERT_SIMPLE_TRIGGER));
ps.setString(1, trigger.getName());
ps.setString(2, trigger.getGroup());
ps.setInt(3, trigger.getRepeatCount());
ps.setBigDecimal(4, new BigDecimal(String.valueOf(trigger
.getRepeatInterval())));
ps.setInt(5, trigger.getTimesTriggered());
return ps.executeUpdate();
} finally {
closeStatement(ps);
}
}
示例8: insertNumeric
import java.sql.PreparedStatement; //导入方法依赖的package包/类
public static void insertNumeric() throws ClassNotFoundException, SQLException {
Class.forName("com.mysql.jdbc.Driver");
Properties from = new Properties();
from.put("user", "root");
from.put("password", "root");
from.put("characterEncoding", "utf8");
Connection conn = DriverManager.getConnection("jdbc:mysql://localhost:3306/erosa", from);
PreparedStatement pst = conn.prepareStatement("insert into unsignednumeric(id,id1,id2,id3) values (?,?,?,?)");
pst.setLong(1, Integer.MAX_VALUE * 2L);
pst.setLong(2, Integer.MIN_VALUE);
pst.setBigDecimal(3, new BigDecimal("18446744073709551614"));
pst.setBigDecimal(4, new BigDecimal(Long.MIN_VALUE + ""));
pst.executeUpdate();
pst.close();
conn.close();
}
示例9: insertFiredTrigger
import java.sql.PreparedStatement; //导入方法依赖的package包/类
/**
* <p>
* Insert a fired trigger.
* </p>
*
* @param conn
* the DB Connection
* @param trigger
* the trigger
* @param state
* the state that the trigger should be stored in
* @return the number of rows inserted
*/
public int insertFiredTrigger(Connection conn, Trigger trigger,
String state, JobDetail job) throws SQLException {
PreparedStatement ps = null;
try {
ps = conn.prepareStatement(rtp(INSERT_FIRED_TRIGGER));
ps.setString(1, trigger.getFireInstanceId());
ps.setString(2, trigger.getName());
ps.setString(3, trigger.getGroup());
setBoolean(ps, 4, trigger.isVolatile());
ps.setString(5, instanceId);
ps.setBigDecimal(6, new BigDecimal(String.valueOf(trigger
.getNextFireTime().getTime())));
ps.setString(7, state);
if (job != null) {
ps.setString(8, trigger.getJobName());
ps.setString(9, trigger.getJobGroup());
setBoolean(ps, 10, job.isStateful());
setBoolean(ps, 11, job.requestsRecovery());
} else {
ps.setString(8, null);
ps.setString(9, null);
setBoolean(ps, 10, false);
setBoolean(ps, 11, false);
}
ps.setInt(12, trigger.getPriority());
return ps.executeUpdate();
} finally {
closeStatement(ps);
}
}
示例10: insertTrigger
import java.sql.PreparedStatement; //导入方法依赖的package包/类
public int insertTrigger(Connection conn, Trigger trigger, String state,
JobDetail jobDetail) throws SQLException, IOException {
ByteArrayOutputStream baos = serializeJobData(trigger.getJobDataMap());
int len = baos.toByteArray().length;
ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());
PreparedStatement ps = null;
int insertResult = 0;
try {
ps = conn.prepareStatement(rtp(INSERT_TRIGGER));
ps.setString(1, trigger.getName());
ps.setString(2, trigger.getGroup());
ps.setString(3, trigger.getJobName());
ps.setString(4, trigger.getJobGroup());
setBoolean(ps, 5, trigger.isVolatile());
ps.setString(6, trigger.getDescription());
ps.setBigDecimal(7, new BigDecimal(String.valueOf(trigger
.getNextFireTime().getTime())));
long prevFireTime = -1;
if (trigger.getPreviousFireTime() != null) {
prevFireTime = trigger.getPreviousFireTime().getTime();
}
ps.setBigDecimal(8, new BigDecimal(String.valueOf(prevFireTime)));
ps.setString(9, state);
if (trigger instanceof SimpleTrigger && ((SimpleTrigger)trigger).hasAdditionalProperties() == false ) {
ps.setString(10, TTYPE_SIMPLE);
} else if (trigger instanceof CronTrigger && ((CronTrigger)trigger).hasAdditionalProperties() == false ) {
ps.setString(10, TTYPE_CRON);
} else {
ps.setString(10, TTYPE_BLOB);
}
ps.setBigDecimal(11, new BigDecimal(String.valueOf(trigger
.getStartTime().getTime())));
long endTime = 0;
if (trigger.getEndTime() != null) {
endTime = trigger.getEndTime().getTime();
}
ps.setBigDecimal(12, new BigDecimal(String.valueOf(endTime)));
ps.setString(13, trigger.getCalendarName());
ps.setInt(14, trigger.getMisfireInstruction());
ps.setBinaryStream(15, bais, len);
ps.setInt(16, trigger.getPriority());
insertResult = ps.executeUpdate();
} finally {
closeStatement(ps);
}
if (insertResult > 0) {
String[] trigListeners = trigger.getTriggerListenerNames();
for (int i = 0; trigListeners != null && i < trigListeners.length; i++) {
insertTriggerListener(conn, trigger, trigListeners[i]);
}
}
return insertResult;
}
示例11: writeBigDecimal
import java.sql.PreparedStatement; //导入方法依赖的package包/类
public static void writeBigDecimal(BigDecimal val, int paramIdx,
int sqlType, PreparedStatement s) throws SQLException {
if (null == val) {
s.setNull(paramIdx, sqlType);
} else {
s.setBigDecimal(paramIdx, val);
}
}
示例12: updateTrigger
import java.sql.PreparedStatement; //导入方法依赖的package包/类
public int updateTrigger(Connection conn, Trigger trigger, String state,
JobDetail jobDetail) throws SQLException, IOException {
ByteArrayOutputStream baos = serializeJobData(trigger.getJobDataMap());
int len = baos.toByteArray().length;
ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());
PreparedStatement ps = null;
int insertResult = 0;
try {
ps = conn.prepareStatement(rtp(UPDATE_TRIGGER));
ps.setString(1, trigger.getJobName());
ps.setString(2, trigger.getJobGroup());
setBoolean(ps, 3, trigger.isVolatile());
ps.setString(4, trigger.getDescription());
long nextFireTime = -1;
if (trigger.getNextFireTime() != null) {
nextFireTime = trigger.getNextFireTime().getTime();
}
ps.setBigDecimal(5, new BigDecimal(String.valueOf(nextFireTime)));
long prevFireTime = -1;
if (trigger.getPreviousFireTime() != null) {
prevFireTime = trigger.getPreviousFireTime().getTime();
}
ps.setBigDecimal(6, new BigDecimal(String.valueOf(prevFireTime)));
ps.setString(7, state);
if (trigger instanceof SimpleTrigger && ((SimpleTrigger)trigger).hasAdditionalProperties() == false ) {
// updateSimpleTrigger(conn, (SimpleTrigger)trigger);
ps.setString(8, TTYPE_SIMPLE);
} else if (trigger instanceof CronTrigger && ((CronTrigger)trigger).hasAdditionalProperties() == false ) {
// updateCronTrigger(conn, (CronTrigger)trigger);
ps.setString(8, TTYPE_CRON);
} else {
// updateBlobTrigger(conn, trigger);
ps.setString(8, TTYPE_BLOB);
}
ps.setBigDecimal(9, new BigDecimal(String.valueOf(trigger
.getStartTime().getTime())));
long endTime = 0;
if (trigger.getEndTime() != null) {
endTime = trigger.getEndTime().getTime();
}
ps.setBigDecimal(10, new BigDecimal(String.valueOf(endTime)));
ps.setString(11, trigger.getCalendarName());
ps.setInt(12, trigger.getMisfireInstruction());
ps.setInt(13, trigger.getPriority());
ps.setBinaryStream(14, bais, len);
ps.setString(15, trigger.getName());
ps.setString(16, trigger.getGroup());
insertResult = ps.executeUpdate();
} finally {
closeStatement(ps);
}
if (insertResult > 0) {
deleteTriggerListeners(conn, trigger.getName(), trigger.getGroup());
String[] trigListeners = trigger.getTriggerListenerNames();
for (int i = 0; trigListeners != null && i < trigListeners.length; i++) {
insertTriggerListener(conn, trigger, trigListeners[i]);
}
}
return insertResult;
}
示例13: hasMisfiredTriggersInState
import java.sql.PreparedStatement; //导入方法依赖的package包/类
/**
* <p>
* Get the names of all of the triggers in the given state that have
* misfired - according to the given timestamp. No more than count will
* be returned.
* </p>
*
* @param conn The DB Connection
* @param count The most misfired triggers to return, negative for all
* @param resultList Output parameter. A List of
* <code>{@link org.quartz.utils.Key}</code> objects. Must not be null.
*
* @return Whether there are more misfired triggers left to find beyond
* the given count.
*/
public boolean hasMisfiredTriggersInState(Connection conn, String state1,
long ts, int count, List<TriggerKey> resultList) throws SQLException {
PreparedStatement ps = null;
ResultSet rs = null;
try {
ps = conn.prepareStatement(rtp(SELECT_HAS_MISFIRED_TRIGGERS_IN_STATE));
ps.setBigDecimal(1, new BigDecimal(String.valueOf(ts)));
ps.setString(2, state1);
rs = ps.executeQuery();
boolean hasReachedLimit = false;
while (rs.next() && (hasReachedLimit == false)) {
if (resultList.size() == count) {
hasReachedLimit = true;
} else {
String triggerName = rs.getString(COL_TRIGGER_NAME);
String groupName = rs.getString(COL_TRIGGER_GROUP);
resultList.add(triggerKey(triggerName, groupName));
}
}
return hasReachedLimit;
} finally {
closeResultSet(rs);
closeStatement(ps);
}
}
示例14: inserirProduto
import java.sql.PreparedStatement; //导入方法依赖的package包/类
public static void inserirProduto(Produto produto) throws SQLException, ClassNotFoundException {
String sql = "INSERT INTO produto (nome, descricao, "
+ "vl_compra, vl_venda, categoria, dt_cadastro)"
+ " VALUES (?, ?, ?, ?, ?, CURRENT_TIMESTAMP)";
Connection connection = null;
PreparedStatement preparedStatement = null;
try {
connection = ConnectionUtils.getConnection();
preparedStatement = connection.prepareStatement(sql);
preparedStatement.setString(1, produto.getNome());
preparedStatement.setString(2, produto.getDescricao());
preparedStatement.setBigDecimal(3, produto.getValorCompra());
preparedStatement.setBigDecimal(4, produto.getValorVenda());
preparedStatement.setString(5, produto.getCategoria());
preparedStatement.execute();
} finally {
if (preparedStatement != null && !preparedStatement.isClosed()) {
preparedStatement.close();
}
if (connection != null && !connection.isClosed()) {
connection.close();
}
}
}
示例15: insertFiredTrigger
import java.sql.PreparedStatement; //导入方法依赖的package包/类
/**
* <p>
* Insert a fired trigger.
* </p>
*
* @param conn
* the DB Connection
* @param trigger
* the trigger
* @param state
* the state that the trigger should be stored in
* @return the number of rows inserted
*/
public int insertFiredTrigger(Connection conn, OperableTrigger trigger,
String state, JobDetail job) throws SQLException {
PreparedStatement ps = null;
try {
ps = conn.prepareStatement(rtp(INSERT_FIRED_TRIGGER));
ps.setString(1, trigger.getFireInstanceId());
ps.setString(2, trigger.getKey().getName());
ps.setString(3, trigger.getKey().getGroup());
ps.setString(4, instanceId);
ps.setBigDecimal(5, new BigDecimal(String.valueOf(System.currentTimeMillis())));
ps.setBigDecimal(6, new BigDecimal(String.valueOf(trigger.getNextFireTime().getTime())));
ps.setString(7, state);
if (job != null) {
ps.setString(8, trigger.getJobKey().getName());
ps.setString(9, trigger.getJobKey().getGroup());
setBoolean(ps, 10, job.isConcurrentExectionDisallowed());
setBoolean(ps, 11, job.requestsRecovery());
} else {
ps.setString(8, null);
ps.setString(9, null);
setBoolean(ps, 10, false);
setBoolean(ps, 11, false);
}
ps.setInt(12, trigger.getPriority());
return ps.executeUpdate();
} finally {
closeStatement(ps);
}
}