How java executes sql scripts and passes parameters

as shown below, use ant.jar to connect to the oracle database and execute the sql script, but if my sql script takes in parameters (for example, through sqlplus: sqlplus user/password@db @ test.sql A B C ), it seems that script parameters are not supported in ant.jar, so I don"t know what good method there is?

public static void main (String [] args) {
SQLExec sqlExec = new SQLExec ();
/ / set database parameters
sqlExec.setDriver ("oracle.jdbc.driver.OracleDriver");
sqlExec.setUrl ("jdbc:oracle:thin:@10.128.x.x:1521:xxsid");
sqlExec.setUserid ("xxuser");
sqlExec.setPassword ("xxpass");
/ the script to be executed
sqlExec.setSrc (new File ("src/data.sql"));
/ / how to deal with
sqlExec.setOnerror ((SQLExec.OnError) (EnumeratedAttribute.getInstance (
SQLExec.OnError.class, "abort"));
sqlExec.setPrint (true); / / sets whether to output
/ / to the file sql.out. If this property is not set, it will be output to the console
sqlExec.setOutput (new File ("src/sql.out"));
sqlExec.setProject (new Project ()); / / by default, otherwise it will make an error
sqlExec.execute ();
}

.
Jun.18,2021

there are many good things to do with database-related operations.

  1. JDBC: writes SQL to query
  2. MyBatis: object mapping
  3. Hibernate: object mapping

in addition, the args of the main method can pass parameters. You can pass in parameters and combine parameters and SQL with String.format in the stupidest way.
for example, the parameter passed through args is ABC, code can be written as follows:

String.format("select * from table where name=%s and age=%s and sex=%s", A, B, C)
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1e9ff31-1a98.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1e9ff31-1a98.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?