Re: [Resin-interest] OraclePreparedStatement under Resin 4.0.22
Thank you Scott - your speedy response is appreciated - I will try it first thing tomorrow. Regards Alan On 20/09/2011 17:41, Scott Ferguson wrote: > On 09/20/2011 09:12 AM, Alan Wright wrote: > >> I am migrating from 2 to 4.00.22 >> >> We make use of OraclePreparedStatement to take advantage of setting >> parameters by name. >> > You should use the JDBC unwrap() method (which is newer than Resin 2): > > PreparedStatement pStmt = conn.prepareStatement(sql); > OraclePreparedStatement ps = pStmt.unwrap(OraclePreparedStatement.class); > > -- Scott > -- Alan Wright Athene Systems tel 0845 230 9803 Athene Systems Limited Registered Office: Shieling House Invincible Road Farnborough GU14 7QU Registered in England and Wales No. 3156080 ___ resin-interest mailing list resin-interest@caucho.com http://maillist.caucho.com/mailman/listinfo/resin-interest
Re: [Resin-interest] OraclePreparedStatement under Resin 4.0.22
On 09/20/2011 09:12 AM, Alan Wright wrote: > I am migrating from 2 to 4.00.22 > > We make use of OraclePreparedStatement to take advantage of setting > parameters by name. You should use the JDBC unwrap() method (which is newer than Resin 2): PreparedStatement pStmt = conn.prepareStatement(sql); OraclePreparedStatement ps = pStmt.unwrap(OraclePreparedStatement.class); -- Scott > This worked fine under Resin 2. > > > > We get the datasource > > try { > > Context env = (Context) new > InitialContext().lookup(Constants.CONTEXT_ENV_ROOT); > ds = (DataSource) env.lookup(Constants.GENERAL_CONNECTION_POOL); > if (ds == null) { > System.out.println(Constants.GENERAL_CONNECTION_POOL + " is > an unknown DataSource"); > } > > } catch (NamingException e) { > e.printStackTrace(); > } > > > > and then in another class we use it: > > > Connection con = null; > list = new java.util.ArrayList(); > > try { > > con = ds.getConnection(); > OraclePreparedStatement ps = (OraclePreparedStatement) > con.prepareStatement(getSQLCommandText()); > etc.. > > > > > BUT under resin 4 we are getting errors that we cannot cast the > com.caucho.sql.UserPreparedStatement to OraclePreparedStatement. > > Do we really have to abandon OraclePreparedStatement and named parameters? > > I have tried casting the connection and such like but the caucho.sql.User > seems to take over everything. > > > > Any help or pointers would be welcome. > > > Thanks > > > > Alan > > > > > > > > ___ resin-interest mailing list resin-interest@caucho.com http://maillist.caucho.com/mailman/listinfo/resin-interest
[Resin-interest] OraclePreparedStatement under Resin 4.0.22
I am migrating from 2 to 4.00.22 We make use of OraclePreparedStatement to take advantage of setting parameters by name. This worked fine under Resin 2. We get the datasource try { Context env = (Context) new InitialContext().lookup(Constants.CONTEXT_ENV_ROOT); ds = (DataSource) env.lookup(Constants.GENERAL_CONNECTION_POOL); if (ds == null) { System.out.println(Constants.GENERAL_CONNECTION_POOL + " is an unknown DataSource"); } } catch (NamingException e) { e.printStackTrace(); } and then in another class we use it: Connection con = null; list = new java.util.ArrayList(); try { con = ds.getConnection(); OraclePreparedStatement ps = (OraclePreparedStatement) con.prepareStatement(getSQLCommandText()); etc.. BUT under resin 4 we are getting errors that we cannot cast the com.caucho.sql.UserPreparedStatement to OraclePreparedStatement. Do we really have to abandon OraclePreparedStatement and named parameters? I have tried casting the connection and such like but the caucho.sql.User seems to take over everything. Any help or pointers would be welcome. Thanks Alan -- Alan Wright Athene Systems tel 0845 230 9803 Athene Systems Limited Registered Office: Shieling House Invincible Road Farnborough GU14 7QU Registered in England and Wales No. 3156080 ___ resin-interest mailing list resin-interest@caucho.com http://maillist.caucho.com/mailman/listinfo/resin-interest