星期二, 一月 16, 2007

test.java

package common;
import java.sql.Connection;import java.sql.ResultSet;import java.sql.SQLException;import java.sql.Statement;
public class Hello {
/** * @param args */ public static void main(String[] args) { DBCon dbcon=new DBCon(); // TODO Auto-generated method stub try{ Connection con=dbcon.getConnection(); Statement stmt=con.createStatement(); ResultSet rs=stmt.executeQuery("select * from test.testtb1"); while(rs.next()) { System.out.println(rs.getInt("id")); } con.close(); }catch(SQLException e){ System.out.println("aaaaa"); while(e != null) { System.out.print("SQL State: " +e.getSQLState()); System.out.print("Vendor Specific code: " +e.getErrorCode()); e = e.getNextException(); }
System.out.println("bbbbbb"); }catch(Exception ex){ ex.getStackTrace(); }finally{ System.out.println("asdfasd"); } }
}

没有评论: