incubator-empire-db-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Rainer Döbele <>
Subject re: Best way to Generate SQL String For JDBC?
Date Sat, 23 Jan 2010 10:58:19 GMT
Hi McKinley,

without trying myself I could imagine that one way of doing it is to add the placeholder by
DBColumnExpr placeholder = db.getValueExpr("?", DataType.UNKNOWN);

Another way should be to override useCmdParam() in DBCommand, which tells the Command class
whether to add the value to the SQL string directly or add it as a command parameter. Unfortunately
this function is private instead of protected with is a mistake.

BTW: Thanks for your patch. I hope I can find the time to apply it this weekend.


McKinley wrote:
> re: Best way to Generate SQL String For JDBC?
> In a web application I want to create highly visited web pages that
> will be a user home page. I want to reduce the processing time it
> takes to generate every last detail on the page including generating a
> query through Empire-db. I would like to cache it as follows:
> Now, I know that Empire-db will not be the bottleneck in this type of
> application. But, I will need to shave off as many 50ms and 100ms
> operations as I can for just this one user page. I will even be
> caching HTML headers and footers at the HTTP level so that only
> dynamic content gets processed through Java. I will be caching the
> rendered database output for the last x number of popular users too.
> I want to do something like the following and use Empire-db for the
> really command creation, but then cache that string and use it with
> JDBC directly to eliminate as much overhead as possible.
> String sqlUserHomePageCmd =
> (String)someApplicationStateCache.get("sqlUserHomePageCmd");
> if(sqlUserHomePageCmd == null) {
>     cmd.clear();
>, post.CommentText);
>, post.ThreadTitle);
>     // cmd.where(;
>     cmd.where("?")); // Don't do the above, but make it
> a prepared statement string
>     sqlUserHomePageCmd = cmd.getSelect();
>     someApplicationStateCache.put(sqlUserHomePageCmd);
> }
> PrepareStatment ps = conn.prepareStatment(someApplicationStateCache);
> ps.setInt(0, someSessionState.getUserID());
> ...
> Thanks,
> McKinley

View raw message