本文整理匯總了Java中java.sql.CallableStatement.setDouble方法的典型用法代碼示例。如果您正苦於以下問題:Java CallableStatement.setDouble方法的具體用法?Java CallableStatement.setDouble怎麽用?Java CallableStatement.setDouble使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類java.sql.CallableStatement
的用法示例。
在下文中一共展示了CallableStatement.setDouble方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: testBug9682
import java.sql.CallableStatement; //導入方法依賴的package包/類
/**
* Tests fix for BUG#9682 - Stored procedures with DECIMAL parameters with
* storage specifications that contained "," in them would fail.
*
* @throws Exception
* if the test fails.
*/
public void testBug9682() throws Exception {
if (!serverSupportsStoredProcedures()) {
return;
}
createProcedure("testBug9682", "(decimalParam DECIMAL(18,0))\nBEGIN\n SELECT 1;\nEND");
CallableStatement cStmt = null;
try {
cStmt = this.conn.prepareCall("Call testBug9682(?)");
cStmt.setDouble(1, 18.0);
cStmt.execute();
} finally {
if (cStmt != null) {
cStmt.close();
}
}
}
示例2: buildProcedureCallableStatement
import java.sql.CallableStatement; //導入方法依賴的package包/類
private static StatementWrapper buildProcedureCallableStatement(String sql,Map<String, Object> pmap,Connection conn){
try {
Map<String,Object> paramMap=new LinkedHashMap<String,Object>();
int leftParnPos=sql.indexOf("(");
int rightParnPos=sql.indexOf(")");
String paramStr="";
if(leftParnPos>-1 && rightParnPos>-1){
paramStr=sql.substring(leftParnPos+1,rightParnPos);
}
int oracleCursorIndex=-1,paramIndex=0;
String[] str=paramStr.split(",");
for(String param:str){
paramIndex++;
param=param.trim();
if(param.toLowerCase().equals("oracle")){
sql=sql.replaceFirst(param, "?");
oracleCursorIndex=paramIndex;
continue;
}else if(!param.startsWith(":")){
continue;
}
sql=sql.replaceFirst(param, "?");
String paramName=param.substring(1,param.length());
Object paramValue=pmap.get(paramName);
paramMap.put(paramName, (paramValue==null ? "" : paramValue));
}
String procedure="{"+sql+"}";
CallableStatement cs= conn.prepareCall(procedure);
int index=1;
for(String name:paramMap.keySet()){
Object value=paramMap.get(name);
if(value instanceof String){
cs.setString(index,(String)value);
}else if(value instanceof Date){
Date date=(Date)value;
cs.setDate(index, new java.sql.Date(date.getTime()));
}else if(value instanceof Integer){
cs.setInt(index, (Integer)value);
}else if(value instanceof Float){
cs.setFloat(index, (Float)value);
}else if(value instanceof Double){
cs.setDouble(index, (Double)value);
}else{
cs.setObject(index, value);
}
index++;
}
if(oracleCursorIndex>-1){
cs.registerOutParameter(oracleCursorIndex, -10);
}
return new StatementWrapper(cs,oracleCursorIndex);
} catch (SQLException e) {
throw new ReportException(e);
}
}