2013-09-06 2 views
0

이상한 문제가 있습니다. MySQL 5.1 데이터베이스에 SELECT 쿼리를 실행하고 UPDATE 쿼리를 커밋하고 다시 SELECT 쿼리를 수행 할 수 없습니다 열 찾기).
가 // UPDATE커밋 된 업데이트 (JDBC, MySQL) 후 열을 찾을 수 없습니다.

PreparedStatement commonUpdate=null; 
    try { 
     String queryUpdate="UPDATE computers SET name=?, serial=?, inv_number=?, comments=?, rack_unit=?, box_unit=?, ram=? WHERE ID=" 
       +currentComp.getComputers_id(); 
     dbhIrmdb.setAutoCommit(false); 
     commonUpdate=dbhIrmdb.prepareStatement(queryUpdate); 
     commonUpdate.setString(1, currentComp.getComputers_name()); 
     ... 
     commonUpdate.executeUpdate(); 
     dbhIrmdb.commit(); 
    } catch (SQLException ex) { 
     ex.printStackTrace(); 
     try { 
      System.err.print("Transaction is being rolled back"); 
      dbhIrmdb.rollback(); 
     } catch(SQLException excep) { 
      excep.printStackTrace(); 
     } 
    } 
    finally { 
     if (commonUpdate != null) { 
      commonUpdate.close(); 
     } 
     dbhIrmdb.setAutoCommit(true); 
    } 

내가 사이트를 통해 깊은 연구를

dbhIrmdb.setAutoCommit(false); 
PreparedStatement preparedSelect=null; 
     preparedSelect=dbhIrmdb.prepareStatement(query); 
     ResultSet rowSet=preparedSelect.executeQuery(); 
     dbhIrmdb.commit(); 
     while (rowSet.next()) { 
      computer=new ComputerInfo(); 
      computer.setIndex(index); index++; 
      computer.setComputers_id(rowSet.getString("computers_id")); 
      .... 
     } 
dbhIrmdb.setAutoCommit(true); 

SELECT // 그러나 나는 이러한 경우를 찾을 수 없습니다 :

여기 내 코드입니다.

도움이나 조언을 주시면 감사하겠습니다.

+0

이 시도하고 ID는 = "+ currentComp.getComputers_id()'. 어서 WHERE 당신은'이 ... –

+0

대문자/소문자가 있습니까? – jaczes

+0

업데이트에는'ID'가 있고 질의에는'computers_id'가 있습니다. 어떤 버전인지 결정해야한다고 생각합니다. 업데이트가 성공하면 'ID'가 올바른 것으로 의심됩니다. one. –

답변

0

computers_id//SELECT block이고 ID//UPDATE입니다. 단 하나 개의 작은 장애물을

당신은 준비된 문을 사용하여 잘 그렇게하고있다 // UPDATE 블록

String queryUpdate="UPDATE computers SET name=?, serial=?, inv_number=?, comments=?, rack_unit=?, box_unit=?, ram=? WHERE computers_id=" 
      +currentComp.getComputers_id(); 
+0

을 catch하면 도움이됩니다. computers_id는 컴퓨터의 별칭입니다. .ID, 내가 그렇게하면 쿼리가 실행되지 않고 'computers'테이블에 computers_id 필드가 없습니다. –

+0

컴퓨터 엔터티 또는 이와 유사하게 스키마 구조를 게시해야합니다. – TheKojuEffect

+0

5.1 대신 MySQL 5.7을 사용해 보겠습니다. 나는 너무 오래된 데이터베이스 서버 버전 때문이라고 생각합니다. –

관련 문제