import java.sql.Connection; import java.sql.SQLException; import java.sql.Statement; import oracle.ConnectionManager; import oracle.exception.GetConnectionException; public class JDBC_EXEC { public static void main(String[] args) throws SQLException, GetConnectionException { String ip="ip"; String user="user"; String password="pwd"; String instanceName="orcl"; ConnectionManager cm=new ConnectionManager(ip,instanceName,user,password); Connection conn=cm.getOracleConnection(); String sql="begin"+ " dbms_stats.gather_table_stats(ownname => 'user',"+ " tabname => 'tableName,"+ " estimate_percent => null,"+ " method_opt => 'for all indexed columns',"+ " cascade => true);"+ " end;"; Statement cs=conn.createStatement(); System.out.println(cs.executeUpdate(sql)); cm.close(cs); cm.close(conn); } }
输出:
1