EJB/JDBC/Stored Procedure


EJB programming & troubleshooting: EJB/JDBC/Stored Procedure

  1. EJB/JDBC/Stored Procedure (3 messages)

    Please forgive me, but this is more of a JDBC type question than EJB, but it's JDBC from within an EJB :-)

    There is a stored procedure on the database I'm using called GETDATE() which, remarkably enough, gets the current date & time.

    How do I access this from within a prepared statement using parameter transformation?

    I want to do the equivelent of:-

    INSERT INTO table1 (cuurent_date) VALUES (?)

    And replace the '?' with GETDATE()

    For strings I use setString, for int I use setInt, what do I use for Stored procedures?


    Threaded Messages (3)

  2. EJB/JDBC/Stored Procedure[ Go to top ]

    String sName = "PACKAGENAME.GETDATE()";
    "INSERT INTO table1 (cuurent_date) VALUES ('"+sName+"') ";

    However, you cannot use stored procedure in a sql statement. You could use functions instead.

  3. EJB/JDBC/Stored Procedure[ Go to top ]

    use callableStatement to call a stored Procedure
    something like

    CallableStatement cs = con.prepareCall("{call Whatever(?,?)}");
  4. EJB/JDBC/Stored Procedure[ Go to top ]

    Thanks to both of you!