@author not attributable @version 1.0 / public class LPWDatabaseOperation { / 使用Oracle格式的DriverManager @see LPWDatabaseOperation#getUseContextType / public final int useOracleDriverManager = 0; / 使用Sybase格式的DriverManager @see LPWDatabaseOperation#getUseContextType / public final int useSybaseDriverManager = 1; / 使用MySQL格式的DriverManager @see LPWDatabaseOperation#getUseContextType / public final int useMysqlDriverManager = 2; / 使用SQLServer格式的DriverManager @see LPWDatabaseOperation#getUseContextType / public final int useSqlserverDriverManager = 3; / 使用DB2格式的DriverManager @see LPWDatabaseOperation#getUseContextType / public final int useDb2DriverManager = 4; / 使用Informix格式的DriverManager @see LPWDatabaseOperation#getUseContextType / public final int useInformixDriverManager = 5; / 使用PostgreSQL格式的DriverManager @see LPWDatabaseOperation#getUseContextType / public final int usePostgresqlDriverManager = 6; / 使用Jdbc-Odbc-Bridge格式的DriverManager @see LPWDatabaseOperation#getUseContextType / public final int useJdbcOdbcBridge = 7; / 使用Tomcate格式的DataSource @see LPWDatabaseOperation#getUseContextType / public final int useTomcateDataSource = 8; / 使用WebLogic格式的DataSource @see LPWDatabaseOperation#getUseContextType / public final int useWeblogicDataSource = 9; / 使用WebSphere格式的DataSource @see LPWDatabaseOperation#getUseContextType / public final int useWebsphereDataSource = 10; ///////////////////////////////////////////////////////// private String[] driverManagerType; private int useContextType; private int pageSize,pageCount,absolutePage,recordCount; ////////////////////////////////////////////////////////// private Connection connection; private PreparedStatement preparedStatement; private ResultSet resultSet;
/ 构造LPWDatabaseOperation。 在构造时需选择所使用的环境类型, LPWDatabaseOperation支持多种主流的DriverManager驱动及DataSource环境, 并定义了一些常用DriverManager和DataSource的标准格式, 其中包括Oracle、Sybase、MySQL、SQLServer等主流数据库的DriverManager格式, 以及Jdbc-Odbc-Bridge的标准格式, 同时还提供了Tomcate、WebLogic和WebSphere下DataSource的标准格式, 程序员在使用时只需要选择相应的常量即可。 @param useContextType int 使用的环境类型 @see LPWDatabaseOperation#getUseContextType / public LPWDatabaseOperation(int useContextType) { if(useContextType<0) useContextType = 0; if(useContextType>7) useContextType = 7; this.useContextType = useContextType; ///////////////////////////////////////////////////////// this.driverManagerType[this.useOracleDriverManager] = new String("oracle.jdbc.driver.OracleDriver"); this.driverManagerType[this.useSybaseDriverManager] = new String("com.sybase.jdbc.SybDriver"); this.driverManagerType[this.useMysqlDriverManager] = new String("com.mysql.jdbc.Driver"); this.driverManagerType[this.useSqlserverDriverManager] = new String("com.microsoft.jdbc.sqlserver.SQLServerDriver"); this.driverManagerType[this.useDb2DriverManager] = new String("com.ibm.db2.jdbc.app.DB2Driver"); this.driverManagerType[this.useInformixDriverManager] = new String("com.informix.jdbc.IfxDriver"); this.driverManagerType[this.usePostgresqlDriverManager] = new String("org.postgresql.Driver"); this.driverManagerType[this.useJdbcOdbcBridge] = new String("sun.jdbc.odbc.JdbcOdbcDrive"); ///////////////////////////////////////////////////////// this.pageSize = 20; this.pageCount = 0; this.absolutePage = 0; this.recordCount = 0; ////////////////////////////////////////////////////////// this.connection = null; this.preparedStatement = null; this.resultSet = null; }