本文整理汇总了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);
}
}