Ernie Stephenson

Greenhorn
+ Follow
since Feb 03, 2004
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Ernie Stephenson

Fair enough... But I think the marrage between RDBMS and OO is a rocky one. If you want to persist objects then use an OO database. Nibernate is good, but I am wondering what it is all for when I hear that access to stored procedures will be implemented?
Most of the applications I work on have hundreds of relational tables. Most of these tables can relate to objects. I still think it's a whole lot quicker to stick a course grained DAO over the top and do all the processing on the db (if possible). Good old client-server style.
As for JDBC, fair enough it's not quite j2ee which means that...

J2EE = Servlet API, JMS. The rest is a bit rubbish really...
From my experience, the only type of EJB i've used (with any degree of success) is a stateless session bean (a glorified biz delegate!). I worked on a few projects using session and entity beans(!) a few years back and it was a complete and utter waste of time and money. I can't see the point of having a resonably flexible language like java chained down by mindless, badly thought out 'frameworks'.
The only time I do a transaction is against a database and it's simple enough to daisy-chain a load of DAO's together and let the JDBC layer worry about the 'transactions'. Granted a more distributed application will require a proper 'transactional' model but i've never worked on one that can't get away with a simple database transaction...
J2EE = Servlet API, JDBC, JMS. The rest is a bit rubbish really...

Ernie
Hello,

The code below is abbreviated. If you try this against an Oracle database you will (from a Tomcat pool) have a connection, with cursors left open. If you could cast the ResultSet/CallableStatement to the Oracle versions then you will not get the cursors left open...

...
CallableStatement stmt = null;
ResultSet rs = null;
List hotels = new ArrayList();
try
{
// prepare the call
stmt =
getConnection().prepareCall(
"{? = call PACKAGE.search(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)}");

// bind the parameters
int count = 1;
stmt.registerOutParameter(count++, OracleTypes.CURSOR);

// ... bind all the stuff

// grab the results
stmt.execute();
rs = (ResultSet)stmt.getObject(1);
while (rs.next())
{
Thing thing= new Thing();

// grab the results
count = 1;
thing= .setX(rs.getString(count++));
thing= .setY(rs.getString(count++));
thing= .setZ(rs.getString(count++));

// add to list
things.add(avail);
}
}
catch (IOException e)
{
// Log this error
LoggerHelper.log(logger, Priority.ERROR, e);

// throw an exception
throw new SQLException("");
}
catch (SQLException e)
{
// Log this error
LoggerHelper.log(logger, Priority.ERROR, e);

// throw an exception
throw new SQLException("");
}
finally
{
// clean up
close(rs);
close(stmt);
closeConnection();
}

// return the things
return things;
...

Cheers,

Ernie
I'd rather not use Oracle specific stuff but the code i use calls a stored procedure. When i close the connection, then free to the pool (i'm using a tomcat pool here), the cursors against the connection remain open for the call to the stored procedure... When i try another way and use the Oracle specific stuff this does not happen... Typical Oracle..

Ernie
Hello,

I've been having some trouble with a CallableStatement against an oracle database. The statements have not been closed properly and leave cursors open on the connection pool. Now I have looked at the doc's and found that you have to use the OracleCallableStatement resultset etc. But this does not seem to be possible from a tomcat datasource since I get a ClassCastException when I try to cast into either of these... I think the root of the problem is Oracle, but I would like to be able to get hold of an OracleConnection from Tomcat and I can't get it? Can any on help out there?

Cheers,

Ernie