The documentation is wrong. Native results should be true in order to use the
resultsset of the Oracle driver. Here is a servlet that I used to test the
compilation:
import javax.servlet.*;
import javax.servlet.http.*;
import java.io.*;
import java.sql.*;
import javax.sql.*;
import javax.naming.*;
import oracle.sql.*;
import oracle.jdbc.driver.*;
public class StoredProcOracleCS extends HttpServlet {
String iDataType = "java.sql.Types.INTEGER";
public void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
//First set things up
//JDBC datasource
String dsName = "oracle";
//Connection object.
Connection dbConnection = null;
//Statement object.
CallableStatement cstmt = null;
OracleCallableStatement ocstmt = null;
//Start servlet output.
PrintWriter out = response.getWriter();
response.setContentType("text/html");
out.println("<html><head><title>DB Test</title></head><body>");
out.println("<h1>JDBC Stored Procedure</h1>");
//Start db access code.
try{ //start first try
InitialContext ctx = new InitialContext();
DataSource ds = (DataSource)ctx.lookup(dsName);
//Create DB connection.
dbConnection = ds.getConnection();
//Create statement using OracleCallableStatement.
ocstmt = (OracleCallableStatement)dbConnection.prepareCall("{call
PROC_SELDEPT2(?,?)}");
ocstmt.setString(1, "RESEARCH");
ocstmt.registerOutParameter(2, java.sql.Types.INTEGER);
ocstmt.execute();
out.println("The department is: " + cstmt.getInt(2));
} //end first try
catch (Exception e){ //start first catch
out.println("<p>Exception in main try block");
e.printStackTrace();
} //end first catch
//Do this no matter what.
finally { //start finally
//Clean up.
try{ //start second try
if (dbConnection != null) {
dbConnection.close();
}
} //end second try
catch (SQLException sqlex) { //start sencond catch
out.println("<p>SQL exception in finally block");
sqlex.printStackTrace();
} //end second catch
} //end finally
//Finish servlet output
out.println("</body></html>");
}
}
-----Original Message-----
From: Budi Prawira [mailto:[EMAIL PROTECTED]]
Sent: Friday, August 02, 2002 3:40 AM
To: JRun-Talk
Subject: RE: ClassCastException: jrun.sql.JRunResultSet
Nope. Still the same ClassCastException.
Checked adminguide.pdf, page 55:
--------------------------------------
native-results: set to true to use cachable, scrollable, updatable JRun
ResultSet implementation. Set to false to use the ResultSet returned by the
underlying JDBC driver.
--------------------------------------
We need to get the OracleCallableStatement, because we need the
getCursor(...) method. How can we achieve that using JRun JDBC service?
regards,
Budi
> -----Original Message-----
> From: Theodore Zimmerman [mailto:[EMAIL PROTECTED]]
> Sent: 01 August 2002 21:14
> To: JRun-Talk
> Subject: RE: ClassCastException: jrun.sql.JRunResultSet
>
>
> Budi,
> Change <native-results>false</native-results> to
> <native-results>true</native-results>. This will use
> Oracle's driver and not JRun's implementation.
>
> HTH.
>
> Ted Zimmerman
>
> -----Original Message-----
> From: Budi Prawira [mailto:[EMAIL PROTECTED]]
> Sent: Wednesday, July 31, 2002 10:43 PM
> To: JRun-Talk
> Subject: RE: ClassCastException: jrun.sql.JRunResultSet
>
>
> Eric,
>
> This is what I did:
> 1. setup a new data source. Below is the result (taken from
> jrun-resources.xml):
> --------------------------------------
> <data-source>
> <dbname>M2M_TEST_DS</dbname>
> <driver>oracle.jdbc.driver.OracleDriver</driver>
> <url>jdbc:oracle:oci8:@isis</url>
> <username>m2m</username>
> <password>A573316D0B3B2DE9C3F46D8B6AB5D6D2</password>
> <encrypted>true</encrypted>
>
> <encryption-class>jrun.security.JRunCrypterForTwofish</encrypt
> ion-class>
> <native-results>false</native-results>
> <remove-on-exceptions>true</remove-on-exceptions>
> <pool-statements>true</pool-statements>
> <initial-connections>1</initial-connections>
> <connection-timeout>1200</connection-timeout>
> <transaction-timeout>20</transaction-timeout>
> <cache-enabled>false</cache-enabled>
> <cache-size>5</cache-size>
> <cache-refresh-interval>30</cache-refresh-interval>
> <jndi-name>M2M_TEST_DS</jndi-name>
> <poolname>Pool</poolname>
> <minimum-size>0</minimum-size>
> <maximum-size>2147483647</maximum-size>
> <user-timeout>20</user-timeout>
> <skimmer-frequency>420</skimmer-frequency>
> <shrink-by>5</shrink-by>
> <maximum-soft>true</maximum-soft>
> <debugging>false</debugging>
> <disable-pooling>false</disable-pooling>
> <description />
> </data-source>
> --------------------------------------
>
> 2. created a test jsp file:
> --------------------------------------
> <%
> try {
> String jndiName = "M2M_TEST_DS";
> InitialContext _context = new InitialContext();
> DataSource ds = (DataSource) _context.lookup(jndiName);
> // bind jndiName
> // msg = ds.getClass().getName(); --> this one returns
> "jrun.sql.JRunDataSource"
> Connection conn = ds.getConnection();
> OracleCallableStatement ocs = (OracleCallableStatement)
> conn.prepareCall("xxx");
> msg = ocs.getClass().getName();
> %>
> msg = <%=msg%>
> <%
> } catch(Exception e) {
> %>
> <pre><%e.printStackTrace(new PrintWriter(out));%></pre>
> <%
> }
> %>
> --------------------------------------
>
> . and this was the result:
> --------------------------------------
> java.lang.ClassCastException: jrun.sql.JRunCallableStatement
> at jrun__test12ejspa._jspService(jrun__test12ejspa.java:75)
> at
> jrun.jsp.runtime.HttpJSPServlet.service(HttpJSPServlet.java:43)
> at jrun.jsp.JSPServlet.service(JSPServlet.java:106)
> at jrun.servlet.ServletInvoker.invoke(ServletInvoker.java:106)
> at
> jrun.servlet.JRunInvokerChain.invokeNext(JRunInvokerChain.java:42)
> at
> jrun.servlet.JRunRequestDispatcher.invoke(JRunRequestDispatche
> r.java:241)
> at
> jrun.servlet.ServletEngineService.dispatch(ServletEngineServic
> e.java:527)
> at
> jrun.servlet.http.WebService.invokeRunnable(WebService.java:172)
> at
> jrunx.scheduler.ThreadPool$DownstreamMetrics.invokeRunnable(Th
> readPool.java:
> 348)
> at
> jrunx.scheduler.ThreadPool$ThreadThrottle.invokeRunnable(Threa
> dPool.java:451
> )
> at
> jrunx.scheduler.ThreadPool$UpstreamMetrics.invokeRunnable(Thre
> adPool.java:29
> 4)
> at jrunx.scheduler.WorkerThread.run(WorkerThread.java:66)
> --------------------------------------
>
> Eric, did I make mistakes somewhere?
>
> regards,
>
> Budi
>
>
>
> > -----Original Message-----
> > From: Eric Anderson [ <mailto:[EMAIL PROTECTED]>
> mailto:[EMAIL PROTECTED]]
> > Sent: 25 July 2002 19:17
> > To: JRun-Talk
> > Subject: RE: ClassCastException: jrun.sql.JRunResultSet
> >
> >
> > When you configure a JDBC data source in JRun 4 you have the
> > option of classifying it as a "native" result set or a
> > non-native" result set. Native result sets return a
> > JRunResultSet that allows the use of cacheable, scrollable
> > and updateable result set. If you use a non-native result
> > set you are returned a result set of the underlying JDBC
> > driver. If you are using the DataDirect driver and try to
> > caste a DataDirect result set as a OracleResult set this
> > could cause your problem.
> >
> > There are a couple of things you can do to work around this
> > behavior. First, (as Budi mentions) bind an data source in
> > JNDI using the Oracle JDBC driver or Oracle connection pool.
> > Note, if any connection pooling was being implemented here it
> > would be Oracle's connection pooling not JRun's. This has
> > the effect of only being able to return an OracleResult set
> > since the DataDirect driver is not being used. Second, try
> > using the Oracle JDBC driver with the JRun connection pool
> > (not the DataDirect driver that we ship with JRun 4). If you
> > do this you will want to set the XML descriptor
> > <native-results>false</native-results> in the
> > jrun-resources.xml. This will make sure you are returning an
> > OracleResult set from the Oracle JDBC driver. Lastly, you
> > could modify your JDBC code so that you
> > do not caste the result set as an OracleResult set.
> >
> > Post back to the list and let us know if this helps.
> >
> > Thanks
> >
> > Eric
> >
> > JRun Support
> > Macromedia Inc.
>
>
>
>
>
______________________________________________________________________
Get the JRun Web Application Construction Kit - the only book written specifically for
JRun developers.
http://www.amazon.com/exec/obidos/ASIN/0789726009/houseoffusion
Archives: http://www.mail-archive.com/[email protected]/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists