ResultSet data_result = dao.getDetails();
Method resultset_method;
resultset_method = data_result.getClass().getMethod("getInt", Integer.class);
它给出错误:
java.lang.NoSuchMethodException: org.apache.commons.dbcp.DelegatingResultSet.getInt(java.lang.Integer)
答案 0 :(得分:0)
public class MainActivity extends AppCompatActivity {
SeekBar seekBar1, seekBar2;
Button start;
Handler handler;
Runnable timer;
boolean running;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
seekBar1 = (SeekBar) findViewById(R.id.seek1);
seekBar2 = (SeekBar) findViewById(R.id.seek2);
start = (Button) findViewById(R.id.start_timer);
start.setOnClickListener(startrListener);
}
private View.OnClickListener startListener = new View.OnClickListener() {
@Override
public void onClick(View v) {
startTimer();
}
};
private void startTimer() {
handler = new Handler();
timer = new Runnable() {
@Override
public void run() {
if (!running) return;
Random rd = new Random();
if (seekBar1.getProgress() >= seekBar1.getMax())
stopTimer();
if (seekBar2.getProgress() >= seekBar2.getMax())
stopTimer();
seekBar1.setProgress(seekBar1.getProgress() + (rd.nextInt(10) + 1));
seekBar2.setProgress(seekBar2.getProgress() + (rd.nextInt(10) + 1));
handler.postDelayed(this, 300);
}
};
handler.postDelayed(timer, 300);
running = true;
}
private void stopTimer() {
running = false;
handler.removeCallbacks(timer);
}
}
的{{1}}方法有两个重载,一个对索引采用ResultSet
,对列名采用getInt
。您正在尝试检索一个确实不存在的int
方法。
您需要提供该方法所采用的类型 - 例如,如果您按名称命名,
String