English 中文(简体)
JDBC方案采用具有复杂投入和产出的储存程序
原标题:JDBC program to invoke stored procedure with complex inputs and output
  • 时间:2012-01-12 15:23:04
  •  标签:
  • java
  • jdbc

您可以帮助我撰写亚行方案,以称之为具有复杂投入类型的下列储存程序。

下面是我的储存程序定义

CREATE OR REPLACE TYPE inputObjects_t AS OBJECT (
    serviceID        VARCHAR2(7),
    offerID          VARCHAR2(7),
    transactionID    NUMBER
)

CREATE OR REPLACE TYPE inputArray_t IS VARRAY(100) OF inputObjects_t

PROCEDURE CheckObjectInput( pCustomerRef IN VARCHAR2,
                                 pSubscriptionPS IN NUMBER,
                                 pExpiryObjects IN inputArray_t,
                                 pTransactionDtm IN DATE,
                                 pTransactionID IN NUMBER);

PROCEDURE CheckObjectOutput( pCustomerRef IN VARCHAR2,
                                 pSubscriptionPS IN NUMBER,
                                 pExpiryObjects OUT inputArray_t,
                                 pTransactionDtm IN DATE,
                                 pTransactionID IN NUMBER);
问题回答

If you use Oracle, please use the class OracleCallableStatement.
There s a method called setSTRUCT.

基因例:

OracleConnection conn = (...)
OracleCallableStatement cs = (OracleCallableStatement) conn.prepareCall(sql);
StructDescriptor sd = StructDescriptor.createDescriptor("MY_TYPENAME", conn);
Object[] attribs = new Datum[3];
attribs[0] = new CHAR("value1",  charSet);
attribs[1] = new CHAR("value2",  charSet);
CLOB clob2 = attribs[2] = new CLOB(conn);
STRUCT st = new STRUCT(sd, conn, attribs);
(...)
cs.setSTRUCT(n, st);
(...)
cs.execute()

你们再想要一个库来储存数据库链接,然后用什么方法把储存的胎盘点。 你们或许想要的是:

public callStoredProc(String serviceID, String offerID, Integer trasnactionID) {
   try {
   myConnection.startTransaction();
   StringBuilder mySQL = new StringBuilder();
   ... build sql statement ...
   myConnection.execute(mySQL.toString());
   } catch (SQLException sqle) {
   ...
   } finally {
      myConnection.endTransaction();
      ... sql cleanup ...
   }
}




相关问题
Spring Properties File

Hi have this j2ee web application developed using spring framework. I have a problem with rendering mnessages in nihongo characters from the properties file. I tried converting the file to ascii using ...

Logging a global ID in multiple components

I have a system which contains multiple applications connected together using JMS and Spring Integration. Messages get sent along a chain of applications. [App A] -> [App B] -> [App C] We set a ...

Java Library Size

If I m given two Java Libraries in Jar format, 1 having no bells and whistles, and the other having lots of them that will mostly go unused.... my question is: How will the larger, mostly unused ...

How to get the Array Class for a given Class in Java?

I have a Class variable that holds a certain type and I need to get a variable that holds the corresponding array class. The best I could come up with is this: Class arrayOfFooClass = java.lang....

SQLite , Derby vs file system

I m working on a Java desktop application that reads and writes from/to different files. I think a better solution would be to replace the file system by a SQLite database. How hard is it to migrate ...

热门标签