zoukankan      html  css  js  c++  java
  • 回调函数

    1、海南室分项目里用的比较多的 js回调函数  callback  查看 积累 文件

    2、定义:

    import java.sql.{ResultSet, DriverManager}

    import com.dtgroup.sparkmr.configuration.DBConnection

    /**
    * The package path is com.dtgroup.sparkmr.dao.
    * Created by tommy duan on 2016/1/4.
    */
    class SQLExecute private {
    def executeQuery(sql:String,callback:ResultSetCallback):Unit = {
    Class.forName(DBConnection.driver)
    val connection = DriverManager.getConnection(DBConnection.url, DBConnection.username, DBConnection.password)
    val statement = connection.createStatement()
    val resultSet = statement.executeQuery(sql)
    if (callback != null) {
    callback.call(resultSet);
    }
    resultSet.close()
    statement.close()
    connection.close()
    }
    }
    定义ResultSetCallback的接口
    import java.sql.ResultSet

    /**
    * The package path is com.dtgroup.sparkmr.dao.
    * Created by tommy duan on 2016/1/7.
    */
    class ResultSetCallback {
    def call(resultSet:ResultSet):Unit={}
    }
    调用:
    SQLExecute.executeQuery("select distinct CellOID, NeighborCellOID from Tuning.Res_NeighborCell order by CellOID", new ResultSetCallback {
    override def call(resultSet: ResultSet) = {
    if (!resultSet.wasNull()) {
    while (resultSet.next()) {
    val cellId = resultSet.getInt("CellOID")
    val neighborCellOID = resultSet.getInt("NeighborCellOID")
    if (!neighborCellMap.contains(cellId)) {
    neighborCellMap += (cellId -> List(neighborCellOID))
    }
    else {
    neighborCellMap(cellId).::(neighborCellOID)
    }
    }
    }
    }
    })
  • 相关阅读:
    IE浏览器下常见的CSS兼容问题
    Android studio 使用问题汇总
    IOS中的属性列表----Property List
    自定义组件-BreadcrumbTreeView 的使用
    IOS开发之数据sqlite使用
    深入分析动态管理Fragment
    IOS开发中多线程的使用
    Java中导入、导出Excel
    IOS数据持久化之归档NSKeyedArchiver
    Bugfree3.0.4 Linux环境安装指南
  • 原文地址:https://www.cnblogs.com/xiaomuchong/p/5200308.html
Copyright © 2011-2022 走看看