Skip to Main Content

Java Database Connectivity (JDBC)

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Interested in getting your voice heard by members of the Developer Marketing team at Oracle? Check out this post for AppDev or this post for AI focus group information.

How can I call a hsqldb procedure from Java

843859Sep 21 2005 — edited Sep 22 2005
Hello,


I am trying to call from Java a stored procedure but I keep having exceptions!!!
In addition, I have no idea how I can get the result of the procedure !!!!
I have spent the whole day in Internet.... no luck!!

===============================================
I[b] java.lang.Exception: +updatejava.sql.SQLException: Unexpected token: # in statement [ call MODIFY_FIELD_SEPARATOR(#) ]
at util.UtilBean.test_upd(UtilBean.java:369)
===============================================

The following procedures have been created and tested withing the database and there work.

- public static String manage_field_separator(String ifs)
-public static String manage_refresh_interval(int val)


The alias have been created:
CREATE ALIAS MODIFY_FIELD_SEPARATOR FOR "com.lucent.util.StoredProcedures.manage_field_separator";

CREATE ALIAS MODIFY_REFRESH_INTERVAL FOR "com.lucent.util.StoredProcedures.manage_frefresh_interval


My file.java contains the flollowing:
public String test_upd(String tableName, String paramValue)
                                     throws Exception
 {
   String res="0";
   Connection conn=null;
   CallableStatement cs= null;
    try
    {
      conn=DBConnection.DBConnect();
      String p="MODIFY_"+tableName.toUpperCase()+"("+paramValue+")";
  
      cs=conn.prepareCall( "{call "+p+"}");
     cs.execute();

       // Suppose to get the result res  of the function!!!!
    }
    catch (SQLException e)
    {
     exceptionMessage="+update"+e.toString();
     System.out.println("exceptionMessage="+exceptionMessage);
     throw new Exception(exceptionMessage);
    }
    finally
    {
      Statement stmt=null;
      DBConnection.closeConnection(conn,stmt);
    }
    return res;
  }
Obviously I am doing something wrong ..... but I don't know what!!!
Could you help me please?

THanks a lot!

Comments

Locked Post
New comments cannot be posted to this locked post.

Post Details

Locked on Oct 20 2005
Added on Sep 21 2005
19 comments
437 views