Java 8 CallableStatement - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Java 8 CallableStatement class.

This code example shows how to use the following methods: getInt, wasNull
    } 
  } 
 
  @Override 
  public E getNullableResult(CallableStatement cs, int columnIndex) throws SQLException {
    int i = cs.getInt(columnIndex);
    if (cs.wasNull()) {
      return null; 
    } else { 
      try { 
        return enums[i];
      } catch (Exception ex) {
        throw new IllegalArgumentException("Cannot convert " + i + " to " + type.getSimpleName() + " by ordinal value.", ex);
      } 
    } 
  } 
   
} 
Full Snippet Info
7
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods: registerOutParameter, executeUpdate, setString
	 
		String stmt =  "call db2gse.ST_unregister_spatial_column(?,?,?,?,?)";
	 
		String s = "{" + stmt + "}";
		CallableStatement ps = con.prepareCall(s);
		ps.setString(1, quote(schemaName));
		ps.setString(2, quote(tableName));
		ps.setString(3, quote(columnName));
		ps.registerOutParameter(4, Types.INTEGER);
		ps.registerOutParameter(5, Types.CHAR);
		ps.executeUpdate();
		//DB2TestSetup.LOGGER.log(Level.INFO,ps.getInt(4) + "|" + ps.getString(5)); 
		 
		 
	} 
 
	static { 
		PARAMETER_MARKES = new HashMap<Class,String>();
		PARAMETER_MARKES.put(Point.class, "DB2GSE.ST_PointFromWKB(cast (? as BLOB(2G)),{0})");
		PARAMETER_MARKES.put(LineString.class, "DB2GSE.ST_LineFromWKB(cast (? as BLOB(2G)),{0})");
Full Snippet Info
7
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods: getInt, getString, registerOutParameter, executeUpdate, setNull
	static protected void enableDB(Connection con) {
		if (ISENABLED) return;
	    try { 
	        CallableStatement s = con.prepareCall(
	                " {call db2gse.ST_enable_db(?,?,?) }"); 
	        s.registerOutParameter(2, Types.INTEGER);
	        s.registerOutParameter(3, Types.CHAR);
	        s.setNull(1, Types.CHAR);
	        s.executeUpdate();
	        DB2TestSetup.LOGGER.log(Level.INFO,s.getInt(2) + "|" + s.getString(3));
	    } catch (SQLException e) {
	        Assert.fail(e.getMessage());
	        DB2TestSetup.LOGGER.log(Level.SEVERE,e.getMessage(),e);
	    } 
	    ISENABLED=true;
	} 
	 
} 
Full Snippet Info
7
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods: getBoolean, getDouble, getFloat, getInt, getLong
	public Object get(Class<?> type, CallableStatement cs, int index) throws SQLException {
		Object value = null; 
		boolean wasNullCheck = false;
 
		if(type == String.class){
			value = cs.getString(index);
 
		} else if(type == Integer.class || type == Integer.TYPE){
			value = cs.getInt(index);
			wasNullCheck = true;
 
		} else if(type == Long.class  || type == Long.TYPE){
			value = cs.getLong(index);
			wasNullCheck = true;
 
		} else if(type == Short.class  || type == Short.TYPE){
			value = cs.getShort(index);
			wasNullCheck = true;
 
		} else if(type == Double.class  || type == Double.TYPE){

6
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods: getInt, registerOutParameter, execute, setString
		int newSeq = 0;
		Connection conn = null;
		try {  
			conn = dataSource.getConnection();
			CallableStatement cstmt = conn.prepareCall("{? = call dbo.p_get_next_sequence(?)}");
	    	cstmt.registerOutParameter(1, Types.INTEGER);
	        cstmt.setString(2, sequenceName);
	        cstmt.execute();
	        newSeq = cstmt.getInt(1);
		} catch (SQLException sqlEx) { 
			log.error("SQLServerSequenceDAO:generateSequence"+sqlEx.getMessage(),sqlEx);
			throw new I2B2DAOException("SQLServerSequenceDAO:generateSequence"+sqlEx.getMessage(),sqlEx);
		} finally {  
			if (conn !=null) {
				try { 
					conn.close();
				} catch (SQLException e) {
					; 
				} 
			} 
Full Snippet Info
6
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods: getObject, execute, getUpdateCount
	private void initializeAddInvoiceWithoutMetaData(boolean isFunction)
			throws SQLException {
		given(databaseMetaData.getDatabaseProductName()).willReturn("MyDB");
		given(databaseMetaData.getUserName()).willReturn("me");
		given(databaseMetaData.storesLowerCaseIdentifiers()).willReturn(true);
		given(callableStatement.execute()).willReturn(false);
		given(callableStatement.getUpdateCount()).willReturn(-1);
		if (isFunction) {
			given(callableStatement.getObject(1)).willReturn(4L);
			given(connection.prepareCall("{? = call add_invoice(?, ?)}")
					).willReturn(callableStatement);
		} 
		else { 
			given(callableStatement.getObject(3)).willReturn(4L);
			given(connection.prepareCall("{call add_invoice(?, ?, ?)}")
					).willReturn(callableStatement);
		} 
	} 
 
	private void verifyAddInvoiceWithoutMetaData(boolean isFunction) throws SQLException {
		if (isFunction) {
Full Snippet Info
8
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods: getString
    return new ByteArrayRef(id);
  } 
 
  @Override 
  public ByteArrayRef getResult(CallableStatement cs, int columnIndex) throws SQLException {
    String id = cs.getString(columnIndex);
    return new ByteArrayRef(id);
  } 
 
} 
Full Snippet Info
6
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods: getInt
  } 
 
  @Override 
  public Integer getNullableResult(CallableStatement cs, int columnIndex)
      throws SQLException {
    return cs.getInt(columnIndex);
  } 
} 
Full Snippet Info
6
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods: getInt, registerOutParameter, execute, setString
            int offsetResult = stmt.executeUpdate(OFFSET_FUNCTION);
            System.out.println("Result: "+offsetResult);
            String sql = "{?=call get_error_offset(?)}";
            System.out.println("Executing sql: "+sql);
            cstmt = con.prepareCall(sql);
            cstmt.registerOutParameter(1, java.sql.Types.INTEGER);
            cstmt.setString(2, "select * from foobar");
            cstmt.execute();
            System.out.println("Offset="+cstmt.getInt(1));
                 
        } catch (SQLException e ) {
            e.printStackTrace();
        } finally { 
            SQLUtilities.closeStatement(cstmt);
            SQLUtilities.closeStatement(stmt);
        } 
         
    } 
     
    /** 
Full Snippet Info
6
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods: getDouble
  } 
 
  @Override 
  public Double getNullableResult(CallableStatement cs, int columnIndex)
      throws SQLException {
    return cs.getDouble(columnIndex);
  } 
 
} 
Full Snippet Info
6
CodeRank
Experience pair programming with AI  Get Codota for Java
See Code Examples for Java 8 CallableStatement Methods: