Connection conn = getConncetion();//获取oracle连接的方法
ResultSet rs = null;
PreparedStatement ps = null;
String sql = "";
try
{
sql = "select * from tablename";
ps = conn.prepareStatement(sql);
rs.excuteQuery(sql);
while(rs != null && rs.next() )
{
String strNo = (String) rs.getObject(1);
String strName = (String) rs.getObject(2);
}
catch(Exception ex)
{
System.out.print(ex.getMessage());
}
finally
{
try
{
conn.close();
ps.close();
rs.close();
}
catch(Exception ex)
{}
}
ResultSet rs = null;
PreparedStatement ps = null;
String sql = "";
try
{
sql = "select * from tablename";
ps = conn.prepareStatement(sql);
rs.excuteQuery(sql);
while(rs != null && rs.next() )
{
String strNo = (String) rs.getObject(1);
String strName = (String) rs.getObject(2);
}
catch(Exception ex)
{
System.out.print(ex.getMessage());
}
finally
{
try
{
conn.close();
ps.close();
rs.close();
}
catch(Exception ex)
{}
}
{
String strNo = rs.getString(1);
String strName = rs.getString(2);
}
试试看