0

プログラムの実行中に常にこのエラーが発生し、エラーの原因がわかりません。エラーは

CheckNList データ読み取りエラーが発生しました java.sql.SQLException: [Microsoft][ODBC Microsoft Access Driver] 更新できませんでした。現在、マシン「PCS」のユーザー「admin」によってロックされています。

コードを以下に示します。いつものお手伝いをお願いします。

public void CheckNList(int SID, int SCOX , int SCOY, int Mission){

        try{
            Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");  
            String url = "jdbc:odbc:SENSOR";
            String user = "";
            String pass = "";
            Connection con = DriverManager.getConnection(url,user,pass);
            Statement stmt  = con.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDATABLE);                      
            Statement stmt2 = con.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDATABLE);                  
            Statement stmt3 = con.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDATABLE);              
            int minLevel = -1;
                stmt2.executeUpdate("delete * from NList WHERE ID=" + SID );
                stmt2.executeUpdate("delete * from NList WHERE NID=" + SID);
                ResultSet rs1 = stmt.executeQuery("select * from InerSN where Spower >0 ");
                while(rs1.next()){
                    int NSID = rs1.getInt("SID");
                    int NSCOX = rs1.getInt("SCOX");
                    int NSCOY = rs1.getInt("SCOY");
                    int NSpower = rs1.getInt("Spower");
                    int NLevelNum = rs1.getInt("LevelNum");
                    int Ntempx = NSCOX- SCOX;
                    int Ntempy = NSCOY- SCOY;
                    int NMission = rs1.getInt("Mission");
                    double distance2 = Math.sqrt(Ntempx*Ntempx + Ntempy*Ntempy);
                    if(distance2 <= Parameter.Sensor_Radius && NSID!= SID){
                        if(minLevel==-1 && NLevelNum>0){
                            minLevel = NLevelNum;
                        }else if(minLevel > NLevelNum && NLevelNum>0){
                            minLevel = NLevelNum;
                        }

                        String QueryUpdate13 = "Insert INTO NList(ID,NID,SCOX,SCOY,Spower,LevelNum,Mission) VALUES (" + SID + "," + NSID + "," + NSCOX + "," + NSCOY + "," + NSpower + "," + NLevelNum + "," + NMission +")";

                        stmt3.executeUpdate(QueryUpdate13);

                        String QueryUpdate15 = "select Spower,LevelNum from InerSN where SID=" + SID;
                        ResultSet rs2 = stmt2.executeQuery(QueryUpdate15);
                        while(rs2.next()){    
                            int Spower2   = rs2.getInt("Spower");
                            String QueryUpdate14 = "Insert INTO NList(ID,NID,SCOX,SCOY,Spower,Mission) VALUES (" + NSID + "," + SID + "," + SCOX + "," + SCOY + "," + Spower2 + "," + Mission +")";

                            stmt3.executeUpdate(QueryUpdate14); 
                        }

                    }                   
                }
                if(minLevel==-1){
                    String Queryupdate16 = "Update InerSN SET LevelNum=" + minLevel + " Where SID=" + SID;
                    stmt2.executeUpdate(Queryupdate16);
                    String Queryupdate17 = "Update NList SET LevelNum=" + minLevel + " Where NID=" + SID;
                    stmt2.executeUpdate(Queryupdate17); 
                }else{
                    minLevel = minLevel + 1;
                    String Queryupdate16 = "Update InerSN SET LevelNum=" + minLevel + " Where SID=" + SID;
                    stmt2.executeUpdate(Queryupdate16);
                    String Queryupdate17 = "Update NList SET LevelNum=" + minLevel + " Where NID=" + SID;
                    stmt2.executeUpdate(Queryupdate17);
                }
                stmt3.close();
                stmt2.close();
                stmt.close();
                con.close();
                //System.out.println("DB Disconnect");
            }catch(Exception e){
                System.out.println("CheckNList data reading error has occurred" + e);
            }           //end of catch 
       }    
4

0 に答える 0