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

📄 dbrowsequence.java

📁 java web 开发,Java Xml 编程指南书籍源码
💻 JAVA
字号:
package MyNa.xml;

import java.sql.*;
import java.util.Hashtable;
import java.util.Enumeration;
import MyNa.utils.*;


public class DBRowSequence extends RowSeq {
  ResultSet theResultSet; Logger lg;

public DBRowSequence(ResultSet R,Env queryInfo)
    throws SQLException,Exception{
  super(); lg=new Logger();
  theResultSet=R; theEnv=queryInfo;
  if(R==null){
    theColumnLabels=null;
    theColumnTypes=null;
    theColumnValues=null;
    theNumberOfColumns=0;
   }else{
  theColumnLabels=MiscDB.resultSetLabels(R);
  theColumnTypes=MiscDB.resultSetTypes(R);
  theEnv.put("theColumnLabels",theColumnLabels);
  theEnv.put("theColumnTypes",theColumnTypes);
  setInitEnv();
  }
}
public DBRowSequence(ResultSet R)
    throws SQLException,Exception{
  this(R,new Env());
}

public boolean next(){
  if(theResultSet==null)return false;
  try{
    if(!theResultSet.next()){
      theResultSet.close();
      theResultSet=null;
      return false;
      }
    for(int i=0;i<theNumberOfColumns;i++){
      String S=theResultSet.getString(i+1);
      if(S==null)S="";
      theColumnValues[i]=S;
      theEnv.put(theColumnLabels[i],S);
      theEnv.put(theFieldValueNum[i],S);
      }
    return true;
}catch(Exception E){lg.logIt("DBSequence.next ERROR:",E);}
  return false;
}
public Env getRow(){
  return theEnv;
}

public void close(){
 try{theResultSet.close(); theResultSet=null;}
 catch(Exception ex){lg.logIt("DBRowSequence.close",ex);}
}
// tools for inheritance, e.g. pruning a rowsequence.


public void shallowClone(RowSeq re){ // a shallow copy
  super.shallowClone(re);
  if(re instanceof DBRowSequence)
    this.theResultSet=((DBRowSequence)re).theResultSet;
}

}

⌨️ 快捷键说明

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