Some thoughts:

1) look at mod_lcr
2) comments on script below...

On Sat, Jun 6, 2009 at 2:53 AM, Shoaib Khanzada <skhanzada@gmail.com> wrote:
Following is the js i am using to select route and bridge the call....


use("ODBC");

var DSN         = "myodbc";
var DB_USER = "neo";
var DB_PASS = ".....";

[...]
 
var db = new ODBC(DSN, DB_USER, DB_PASS);

db.connect();

[...]
 

sql = "SELECT  ec.* FROM auth_routes_carriers arc,external_carriers ec, codes c where arc.external_carriers_id = ec.id and arc.code_id = c.id and substring('"+no2+"',1,length(c.code))=c.code and ec.active=1 order by arc.priority asc";

db.connect();

no need to reconnect
 

db.query(sql);

[...]
 

if(bridge_str != ''){
    if(session.ready()) session.execute("bridge", bridge_str);   

Don't actually execute the bridge from javascript.  Instead, set the bridge_str to a channel var and then do the bridge from the dialplan using that bridge_str.  This way you don't have a javascript interpreter lying around for the duration of the call.
 

--
-Rupa