2016-09-30 4 views
0

두 개의 jspinners가 있습니다. 하나는 HH : mm 형식을 포함하고 다른 하나는 간단한 숫자 (int) 회 전자입니다. SAVE 버튼 내가 TIMELIMIT (유형 시간) 및 시도 (int 형) 열이 포함 된 데이터베이스 테이블을 업데이트 할 클릭데이터베이스에 jspinner 시간 값을 삽입하십시오.

enter image description here

. 하지만 내 데이터베이스에서 시간 형식에 jspinner 값을 저장하는 방법을 모른다.

String update = "Update qbank SET timeLimit = ? and attempts = ? where qbankID = ?"; 
      preparedStatement = connection.prepareStatement(update); 

      preparedStatement.setTime(1, spinnerTime.getValue()); 

나는 위의 코드를 시도했지만 마지막 부분은 시간을 필요로) spinnerTime.getValue 개체 및 setTime (이다라는 오류가 있습니다. 어떻게 시간을 변환하고 반대 할 수 있습니까? 또는 내 데이터베이스에 시간 값을 가진 jspinner를 삽입하는 다른 방법이 있습니까? 어떤 도움을 주시면 감사하겠습니다!

+0

자바와 자바 스크립트의 차이점을 모르겠다. – R3tep

답변

1

단순한 간과 된 문제였습니다. 방금이 코드를 작성했습니다.

Time time; int attempt; 
      time = (Time) spinnerTime.getValue(); 
      attempt = Integer.parseInt(spinnerAttempt.getValue().toString()); 

     String update = "Update qbank SET timeLimit = ? and attempts = ? where qbankID = ?"; 
     preparedStatement = connection.prepareStatement(update); 

     preparedStatement.setTime(1, time); 
     preparedStatement.setInt(2, attempt); 
     preparedStatement.setInt(3, qbankID); 
     preparedStatement.executeUpdate(); 
+0

우아한 ...! .......... – Viney

관련 문제