|
}
// ------------------------------------------------------------------------------------
//连接数据库的方法
public void open()
throws SQLException {
if( conn!=null && !conn.isClosed() )
throw new SQLException( "The connection has been established already." ) ;
clear () ;
pool=new DBPool();
conn = pool.getPool("your_data_source_name").getConnection();
}
//执行SQL语句的方法,将JDBC中的executeQuary()和executeUpdate()两个方法//合而为一,注意返回值为整形,
public int execSQL( String sqlStmt )
throws SQLException {
if( conn==null || conn.isClosed() )
throw new SQLException( "This connection has not been established yet." ) ;
if( sqlStmt==null )
throw new SQLException( "SQL-statement is null." ) ;
clear () ;
conn.setAutoCommit( true ) ;
stmt=conn.createStatement() ;
if( sqlStmt.toUpperCase().startsWith( "SELECT" ) ) {
rs=stmt.executeQuery( sqlStmt ) ;
return -1 ;
}
else {
int numRow=stmt.executeUpdate( sqlStmt ) ;
clear() ;
return numRow ;
}
}
//获取字段值,参数为整形——字段次序
public String getString( int fieldNo )
throws SQLException {
return rs.getString(fieldNo) ;
}
//获取字段值,参数为字符串——字段名
public String getString( String fieldName )
throws SQLException {
return rs.getString(fieldName) ;
}
//上移指针
public boolean previous()
throws SQLException {
上一页 [1] [2] [3] [4] 下一页 [C语言系列]C# 和 Linux 时间戳转换 [Web开发]PHP flock文件锁介绍 [Web开发]flock() Linux下的文件锁 [电脑应用]Linux下的六个免费的虚拟主机管理系统介绍 [电脑应用]Linux数据库大比拚 [操作系统]在Windows中玩转Linux操作系统 [办公软件]在RedHat Linux 9里安装gaim0.80 [办公软件]掌握 Linux 调试技术 [办公软件]理解 Linux 配置文件 [聊天工具]Real10 & Xpdf installation on Linux Box
|