Search code examples
javaspringstored-proceduresjdbcpojo

How do I set the name of the stored procedure in the database using StoredProcedure after creating


How do I set the name of the stored procedure in the database using StoredProcedure after creating.

I don't want to use the Constructor for the Spring JDBC StoredProcedure Object that I have to pass in the datasource and the name.

protected StoredProcedure(DataSource ds, String name)
ds - DataSource to use throughout the lifetime of this object to obtain connections
name - name of the stored procedure in the database

This is due to trying to use POJO. So I want to use the Constructor without them and then call setDataSource on the StoredProcedure but how do I then set the name?

hmm please hel[p


Solution

  • StoredProcedure is designed for extension but if you do want to set it you can use

    RdbmsOperation.setSql(String name)
    

    RdbmsOperation is higher up the type hierarchy of StoredProcedure.

    Essentially all the StoredProcedure's constructor does is call that method with the string passed in.