⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 sql.java

📁 这是一个基于计算网格的web service。它用java编写。一旦安装完成
💻 JAVA
📖 第 1 页 / 共 5 页
字号:
        } catch ( SQLException sqle ) {            throw sqle;                    } catch ( Exception e ) {            throw e;                    } finally {            try {                if( rs != null ) {                    rs.close();                    rs = null;                }            } catch ( Exception e ) {}                                    try {                if( stmt != null ) {                    stmt.close();                    stmt = null;                }                                          } catch ( Exception e ) {}                    }            }                public static void setJobExitMessage(             Connection conn,             String jobId,             String message )            throws SQLException, Exception {        Statement stmt = null;         String sqlstr = null;         ResultSet rs = null;        Timestamp started = null;        try {            stmt = conn.createStatement();                        sqlstr =                 "SELECT * FROM " + TBL_JOBS_CURR + " WHERE " +                JOB_COL_JOBID + " = " + "'" + jobId + "'";                        if ( stmt.execute( sqlstr ) ) {                rs = stmt.getResultSet();                                if ( rs.next() ) {                    sqlstr =                             "UPDATE " + TBL_JOBS_CURR + " SET " +                            JOB_COL_EXITMSG + " = '" + message + "'" +                            " WHERE " + JOB_COL_JOBID + " = " +                            "'" + jobId + "'";                    stmt.execute( sqlstr );                    if ( stmt.getUpdateCount() == 0 ) {                        throw new SQLException(                                 "SQL UPDATE failed on table " +                                "'" + TBL_JOBS_CURR + "'" );                      }                                      } else {                    throw new SQLException(                             "a job with id '" + jobId + "' was not found" );                }                             } else {                throw new SQLException(                         "SQL SELECT failed on table " +                         "'" + TBL_JOBS_CURR + "'" );                            }                     } catch ( SQLException sqle ) {            throw sqle;                    } catch ( Exception e ) {            throw e;                    } finally {            try {                if( rs != null ) {                    rs.close();                    rs = null;                }            } catch ( Exception e ) {}                                    try {                if( stmt != null ) {                    stmt.close();                    stmt = null;                }                                          } catch ( Exception e ) {}                    }            }          public static void setJobStartTs( Connection conn, String jobId )    throws SQLException, Exception     {        Statement stmt = null;         String sqlstr = null;         ResultSet rs = null;        String currTime = new Timestamp( System.currentTimeMillis() ).toString();        try         {            stmt = conn.createStatement();                        sqlstr =                 "SELECT * FROM " + TBL_JOBS_CURR + " WHERE " +                JOB_COL_JOBID + " = " + "'" + jobId + "'";                        if ( stmt.execute( sqlstr ) )             {                rs = stmt.getResultSet();                                if ( rs.next() )                 {                    sqlstr =                             "UPDATE " + TBL_JOBS_CURR +                             " SET " +                            JOB_COL_TS_START + " = '" + currTime + "'" +                            " WHERE " +                             JOB_COL_JOBID + " = " +"'" + jobId + "'";                    stmt.execute( sqlstr );                    if ( stmt.getUpdateCount() == 0 )                     {                        throw new SQLException(                                 "SQL UPDATE failed on table " +                                "'" + TBL_JOBS_CURR + "'" );                      }                                   }                                 else                 {                    throw new SQLException(                             "a job with id '" + jobId + "' was not found" );                }             }                         else             {                throw new SQLException(                         "SQL SELECT failed on table '" + TBL_JOBS_CURR + "'" );                            }                     } catch ( SQLException sqle ) {            throw sqle;                    } catch ( Exception e ) {            throw e;                    } finally {            try {                if( rs != null ) {                    rs.close();                    rs = null;                }            } catch ( Exception e ) {}                                    try {                if( stmt != null ) {                    stmt.close();                    stmt = null;                }                                          } catch ( Exception e ) {}                    }            }            public static void setJobCompleteTs( Connection conn, String jobId )            throws SQLException, Exception     {        Statement stmt = null;         String sqlstr = null;         ResultSet rs = null;        String currTime = new Timestamp( System.currentTimeMillis() ).toString();        try         {            stmt = conn.createStatement();                        sqlstr =                 "SELECT * FROM " + TBL_JOBS_CURR + " WHERE " +                JOB_COL_JOBID + " = " + "'" + jobId + "'";                        if ( stmt.execute( sqlstr ) ) {                rs = stmt.getResultSet();                                if ( rs.next() )                 {                                               sqlstr =                             "UPDATE " + TBL_JOBS_CURR +                             " SET " +                            JOB_COL_TS_COMPLETE + " = '" + currTime + "'" +                            " WHERE " +                             JOB_COL_JOBID + " = " + "'" + jobId + "'";                    stmt.execute( sqlstr );                    if ( stmt.getUpdateCount() == 0 )                     {                        throw new SQLException(                                 "SQL UPDATE failed on table " +                                "'" + TBL_JOBS_CURR + "'" );                      }                                   }                                  else                 {                    throw new SQLException(                             "a job with id '" + jobId + "' was not found" );                }             }                         else             {                throw new SQLException(                         "SQL SELECT failed on table '" + TBL_JOBS_CURR + "'" );                            }                     } catch ( SQLException sqle ) {            throw sqle;                    } catch ( Exception e ) {            throw e;                    } finally {            try             {                if ( rs != null )                 {                    rs.close();                    rs = null;                }            }             catch ( Exception e ) {}                                    try             {                if ( stmt != null )                 {                    stmt.close();                    stmt = null;                }                                          }             catch ( Exception e ) {}                    }     }        public static void removeCurrJob( Connection conn, String jobId )         throws SQLException, Exception {        Statement stmt = null;         String sqlstr = null;         try {            stmt = conn.createStatement();                        sqlstr =                 "DELETE FROM " + TBL_JOBS_CURR + " WHERE " +                JOB_COL_JOBID + " = " + "'" + jobId + "'";                        stmt.execute( sqlstr );                    } catch ( SQLException sqle ) {            throw sqle;                    } catch ( Exception e ) {            throw e;                    } finally {            try {                if( stmt != null ) {                    stmt.close();                    stmt = null;                }                                          } catch ( Exception e ) {}                    }            }        public static void removeHistJob( Connection conn, String jobId )         throws SQLException, Exception {        Statement stmt = null;         String sqlstr = null;         try {            stmt = conn.createStatement();                        sqlstr =                 "DELETE FROM " + TBL_JOBS_HIST + " WHERE " +                JOB_COL_JOBID + " = " + "'" + jobId + "'";                        stmt.execute( sqlstr );                    } catch ( SQLException sqle ) {            throw sqle;                    } catch ( Exception e ) {            throw e;                    } finally {            try {                if( stmt != null ) {                    stmt.close();                    stmt = null;                }                                          } catch ( Exception e ) {}                    }            }            public static void insertCurrJob(             Connection conn,             String ownerId,            String onwerEmail,            String jobId,            String jobDescr,            int jobIndex,            int status ) throws SQLException, Exception {               Statement stmt = null;         String sqlstr = null;         String currTime = new Timestamp( System.currentTimeMillis() ).toString();                if ( onwerEmail == null ) {            onwerEmail = "";        }                try {            stmt = conn.createStatement();             // note that timestamps for START and COMPLETE are also added            //  --  if these entries are left blank, they default to            //      `000000000` and cause errors when retrieveing job results                        sqlstr =                      "INSERT INTO " + TBL_JOBS_CURR +                    " ( " +                     JOB_COL_OWNERID +           "," +                     JOB_COL_OWNEREMAIL +        "," +                    JOB_COL_JOBID +             "," +                     JOB_COL_JOBSTATUS +         "," +                    JOB_COL_JOBDESCR +          "," +                    JOB_COL_JOBINDEX +          "," +                    JOB_COL_STARTJOB +          "," +                    JOB_COL_TS_SUBMIT +         "," +                    JOB_COL_TS_START +          "," +                    JOB_COL_TS_COMPLETE +                    " ) VALUES ( " +                    "'" + ownerId + "'" +       "," +                    "'" + onwerEmail + "'" +    "," +                    "'" + jobId + "'" +         "," +                    status +                    "," +                    "'" + jobDescr + "'" +      "," +                    jobIndex +                  "," +                    0 +                         "," +                    "'" + currTime + "'" +      "," +                    "'" + currTime + "'" +      "," +                    "'" + currTime + "'" +                     " )";            stmt.execute( sqlstr );        } catch ( SQLException sqle ) {            throw sqle;                    } catch ( Exception e ) {            throw e;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -