日期:2014-05-20 浏览次数:20823 次
class myConnection { ResultSet re; String strurl = "jdbc:odbc:sun"; public myConnection() { } public ResultSet getResult(String sql) { try { Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); Connection conn=DriverManager.getConnection(strurl); Statement stmt=conn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDATABLE); ResultSet re=stmt.executeQuery(sql); return re; } catch(Exception e) { System.out.println("getResult------"+e.toString()); return null; } } public boolean executeSql(String sql) { try { Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); Connection conn=DriverManager.getConnection("jdbc:odbc:sun", "", ""); Statement stmt=conn.createStatement(); stmt.executeUpdate(sql); conn.commit(); return true; } catch(Exception e) { System.out.println("executeSql----"+e.toString()); return false; } } }