执行Sql块
时间:2021-07-01 10:21:17
帮助过:19人阅读
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
执行Sql块
标签: