The functionality that discussed within this question is to execute the given SQL script. The content of the script is intended to be defined by the user during application runtime. The script can be whether one INSERT
statement or a sequence of complex PL/SQL
statements. Since the input available during runtime (eventually as String instance) it should be executed through Java.
Current approach is wrapping user input with a PreparedStatement
and to execute it. This solution works for the existing test cases. The main concern is to provide the full functionality of the used database that might be not covered by tests, i.e. solution that is closest to passing the same user SQL script into database vendor's provided console.
I'm wondering are there any not envisaged limitations in current approach with PreparedStatement
? Is there any better general approach for SQL script execution via Java?
To execute a SQL statement with the execute method, call it by passing it a valid SQL statement as a String object, or as a string literal, as shown in the following example: boolean isResultSet = false; Statement stmt = null; try { stmt = conn. createStatement( ); isResultSet = stmt.
Description: The method used for all types of SQL statements, and that is, returns a Boolean value of TRUE or FALSE. Return type: This method return a Boolean value. TRUE indicates that query returned a Result Set object and FALSE indicate returned an int value or returned nothing.
Well, this is a broad design question but I think that there are several steps that could be done:
Please consider:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With