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

📄 sql.java

📁 这是一个基于计算网格的web service。它用java编写。一旦安装完成
💻 JAVA
📖 第 1 页 / 共 5 页
字号:
                    } finally {             try {                if( stmt != null ) {                    stmt.close();                    stmt = null;                }                                          } catch ( Exception e ) {}                    }    }      public static JobResult getJob(             Connection conn,             String jobId,             boolean searchHistory )     throws SQLException, Exception {        Statement stmt = null;         ResultSet rs = null;         String sqlstr = null;        JobResult result = 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() ) {                     result = new JobResult(                             rs.getString( JOB_COL_OWNERID ),                            rs.getString( JOB_COL_OWNEREMAIL ),                            rs.getString( JOB_COL_JOBID ),                            rs.getString( JOB_COL_JOBDESCR ),                            rs.getInt( JOB_COL_JOBINDEX ),                            rs.getInt( JOB_COL_JOBSTATUS ),                            rs.getInt( JOB_COL_STARTJOB ),                            rs.getInt( JOB_COL_EXITVAL ),                            rs.getString( JOB_COL_EXITMSG ),                            rs.getString( JOB_COL_TS_SUBMIT ),                            rs.getString( JOB_COL_TS_START ),                             rs.getString( JOB_COL_TS_COMPLETE ) );                   }                                else if ( searchHistory ) {                    sqlstr =                             "SELECT * FROM " + TBL_JOBS_HIST + " WHERE " +                            JOB_COL_JOBID + " = '" + jobId + "'";                    if ( stmt.execute( sqlstr ) ) {                        rs = stmt.getResultSet();                        if ( rs.next() ) {                             result = new JobResult(                                     rs.getString( JOB_COL_OWNERID ),                                    rs.getString( JOB_COL_OWNEREMAIL ),                                    rs.getString( JOB_COL_JOBID ),                                    rs.getString( JOB_COL_JOBDESCR ),                                    rs.getInt( JOB_COL_JOBINDEX ),                                    rs.getInt( JOB_COL_JOBSTATUS ),                                    rs.getInt( JOB_COL_STARTJOB ),                                    rs.getInt( JOB_COL_EXITVAL ),                                    rs.getString( JOB_COL_EXITMSG ),                                    rs.getString( JOB_COL_TS_SUBMIT ),                                    rs.getString( JOB_COL_TS_START ),                                     rs.getString( JOB_COL_TS_COMPLETE ) );                           }                            else {                            throw new SQLException(                                     "a job with id '" + jobId + "' was not found" );                                             }                    } else {                        throw new SQLException(                                 "SQL SELECT failed on table '" + TBL_JOBS_HIST + "'" );                    }                                    }                                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 ) {}                    }                return result;    }               public static List<JobResult> getJobs(             Connection conn,             String ownerId,            boolean searchHistory )     throws SQLException, Exception {        Statement stmt = null;         ResultSet rs = null;         String sqlstr = null;        Vector<JobResult> list = new Vector();                  try {                               stmt = conn.createStatement();            sqlstr =                     "SELECT * FROM " + TBL_JOBS_CURR +                    " WHERE " + JOB_COL_OWNERID + " = '" + ownerId + "'";                                     if ( stmt.execute( sqlstr ) ) {                rs = stmt.getResultSet();                                while ( rs.next() ) {                     list.add( new JobResult(                             rs.getString( JOB_COL_OWNERID ),                            rs.getString( JOB_COL_OWNEREMAIL ),                            rs.getString( JOB_COL_JOBID ),                            rs.getString( JOB_COL_JOBDESCR ),                            rs.getInt( JOB_COL_JOBINDEX ),                            rs.getInt( JOB_COL_JOBSTATUS ),                            rs.getInt( JOB_COL_STARTJOB ),                            rs.getInt( JOB_COL_EXITVAL ),                            rs.getString( JOB_COL_EXITMSG ),                            rs.getString( JOB_COL_TS_SUBMIT ),                            rs.getString( JOB_COL_TS_START ),                             rs.getString( JOB_COL_TS_COMPLETE ) ) );                    }                                            }                         else {                throw new SQLException(                         "SQL SELECT failed on table '" + TBL_JOBS_CURR + "'" );            }                        if ( searchHistory ) {                     sqlstr =                         "SELECT * FROM " + TBL_JOBS_HIST +                        " WHERE " + JOB_COL_OWNERID + " = '" + ownerId + "'";                             if ( stmt.execute( sqlstr ) ) {                    rs = stmt.getResultSet();                    while ( rs.next() ) {                         list.add( new JobResult(                                 rs.getString( JOB_COL_OWNERID ),                                rs.getString( JOB_COL_OWNEREMAIL ),                                rs.getString( JOB_COL_JOBID ),                                rs.getString( JOB_COL_JOBDESCR ),                                rs.getInt( JOB_COL_JOBINDEX ),                                rs.getInt( JOB_COL_JOBSTATUS ),                                rs.getInt( JOB_COL_STARTJOB ),                                rs.getInt( JOB_COL_EXITVAL ),                                rs.getString( JOB_COL_EXITMSG ),                                rs.getString( JOB_COL_TS_SUBMIT ),                                rs.getString( JOB_COL_TS_START ),                                 rs.getString( JOB_COL_TS_COMPLETE ) ) );                        }                                }                 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 ) {}                    }                return list;    }                public static List<JobResult> getCurrJobs(             Connection conn,             int status,             boolean equals )     throws SQLException, Exception     {        Statement stmt = null;         ResultSet rs = null;         String sqlstr = null;        Vector list = new Vector();        String operator = null;                if ( equals ) {            operator = " = ";                    } else {            operator = " != ";        }                      try {                               stmt = conn.createStatement();                        sqlstr =                     "SELECT * FROM " + TBL_JOBS_CURR + " WHERE " +                    JOB_COL_JOBSTATUS + operator + status;                                        if( stmt.execute( sqlstr ) ) {                rs = stmt.getResultSet();                                while ( rs.next() ) {                     list.add( new JobResult(                             rs.getString( JOB_COL_OWNERID ),                            rs.getString( JOB_COL_OWNEREMAIL ),                            rs.getString( JOB_COL_JOBID ),                            rs.getString( JOB_COL_JOBDESCR ),                            rs.getInt( JOB_COL_JOBINDEX ),                            rs.getInt( JOB_COL_JOBSTATUS ),                            rs.getInt( JOB_COL_STARTJOB ),                            rs.getInt( JOB_COL_EXITVAL ),                            rs.getString( JOB_COL_EXITMSG ),                            rs.getString( JOB_COL_TS_SUBMIT ),                            rs.getString( JOB_COL_TS_START ),                             rs.getString( JOB_COL_TS_COMPLETE ) ) );                    }                                            }                         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 ) {}                    }                return list;    }            public static List<JobResult> getCurrJobs( Connection conn )     throws SQLException, Exception {        Statement stmt = null;         ResultSet rs = null;         String sqlstr = null;         Vector list = new Vector();                      try {                               stmt = conn.createStatement();                        sqlstr = "SELECT * FROM " + TBL_JOBS_CURR;                        if( stmt.execute( sqlstr ) ) {                rs = stmt.getResultSet();                                while ( rs.next() ) {                     list.add( new JobResult(                             rs.getString( JOB_COL_OWNERID ),                            rs.getString( JOB_COL_OWNEREMAIL ),                            rs.getString( JOB_COL_JOBID ),                            rs.getString( JOB_COL_JOBDESCR ),                            rs.getInt( JOB_COL_JOBINDEX ),                            rs.getInt( JOB_COL_JOBSTATUS ),                            rs.getInt( JOB_COL_STARTJOB ),                            rs.getInt( JOB_COL_EXITVAL ),                            rs.getString( JOB_COL_EXITMSG ),                            rs.getString( JOB_COL_TS_SUBMIT ),                            rs.getString( JOB_COL_TS_START ),                             rs.getString( JOB_COL_TS_COMPLETE ) ) );                     }                                            } 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 ) {}                    }        return list;    }         public static List<JobResult> getHistJobs( Connection conn )     throws SQLException, Exception     {        Statement stmt = null;         ResultSet rs = null;         String sqlstr = null;         Vector list = new Vector();                      try {                   

⌨️ 快捷键说明

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