Tony Edwards wrote:
Hi Alberto,
I'm not too sure about PreparedStatements in Oracle, but I connect to a database using jdbc from flow like this:

function getConnection(){
   //I obtain these values from an xml file
   var dbUrl = "jdbc:oracle:thin:@servername:1521:dbname";
   var dbUSerName = "guest";
   var dbPassWord = "pwrd";

   try{
var jdbc = java.sql.DriverManager.getConnection(dbUrl, dbUserName, dbPassWord)
   } catch (error) {
       setMessage("Error conecting to database! " + error);
       return null;
   }
   var conn = new Database(jdbc);
   return conn;
}

The line of interest is the "java.sql.DriverManager.getConnection()" which does all the magic. Then I pass this to the Database function in Database.js.

Hope this helps.

Yes, this is a solution. But I wished to use cocoon datasource.
After many attempt I found the following solution:

importClass(Packages.oracle.sql.ARRAY);
importClass(Packages.oracle.jdbc.OracleConnection);

...
var oc = conn.unwrap(OracleConnection); // the way to obtain an OracleConnection instance
...
stmt.setArray(idx, oc.createARRAY(SQLTYPE, ArrayValues));
...


SQLTYPE must be an array type defined in your database

This work only with jdbc driver 11g. With older versions you have to follow another way, slightly different, using ArrayDescriptor class.

Alberto





Alberto Brosich wrote:

I need to use PreparedStatement with parameters that are arrays within a flowscript. Dealing with arrays onto a jdbc connection means use special functions provided by the jdbc driver. In my case the oracle driver has a function |*ArrayDescriptor.createDescriptor <http://www.rakeshv.org/docs/oracle/jdbc3.0/oracle/sql/ArrayDescriptor.html#createDescriptor%28java.lang.String,%20java.sql.Connection%29>*(java.lang.String name, java.sql.Connection conn) that needs a ||java.sql.Connection connection. Within a flowscript I only know how to obtain a |org.apache.cocoon.components.flow.javascript.ScriptableConnection using Database.js from petstore block.
I did not found how to have |||java.sql.Connection from it.|
I would not use more complicated solutions like hibernate (I have to do a "simple" select builded in a dynamic way, so using an orm framework is not so useful) but...

Any suggest?

Alberto

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to