简体   繁体   中英

ORA-00900: invalid SQL statement while exporting an Oracle database from Java

Executing below command from the command line is successful, but executing the same command from a Java class throws an "invalid SQL statement"-error.

EXPDP DCR/DCR2017 DIRECTORY=D33 DUMPFILE=DCR.DMP SCHEMAS=DCR  

Java Code:

  String sql ="EXPDP DCR/DCR2017 DIRECTORY=D33 DUMPFILE=DCR.DMP SCHEMAS=DCR";
  Class.forName("oracle.jdbc.driver.OracleDriver");  

  Connection connection = DriverManager.getConnection("jdbc:oracle:thin:@//localhost:1521/orcl","DCR","DCR2017");
  PreparedStatement prepareStatement = connection.prepareStatement(sql);
  boolean execute = prepareStatement.execute();
  System.out.println(execute);

You cannot call expdp from SQL. It's a command-line function. There is a PL/SQL API for that called dbms_datapump , which you can call from PL/SQL.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM