Java Code Examples for java.sql.CallableStatement.setDouble()

The following are Jave code examples for showing how to use setDouble() of the java.sql.CallableStatement class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
Example 1
Project: the-vigilantes   File: CallableStatementRegressionTest.java   Source Code and License Vote up 6 votes
/**
 * 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();
        }
    }
}
 
Example 2
Project: OpenVertretung   File: CallableStatementRegressionTest.java   Source Code and License Vote up 6 votes
/**
 * 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();
        }
    }
}
 
Example 3
Project: ProyectoPacientes   File: CallableStatementRegressionTest.java   Source Code and License Vote up 6 votes
/**
 * 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();
        }
    }
}
 
Example 4
Project: BibliotecaPS   File: CallableStatementRegressionTest.java   Source Code and License Vote up 6 votes
/**
 * 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();
        }
    }
}
 
Example 5
Project: ureport   File: ProcedureUtils.java   Source Code and License Vote up 4 votes
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);
	}
}