执行Sql块

 

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

 

http://stackoverflow.com/questions/6214172/pl-sql-call-from-jdbc-resulting-in-sqlsyntaxerrorexception-ora-00900/6214370#6214370

 

郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。