如果没有插入查询,我想在javascript中捕获异常.
我写了下面的代码:
var adoConn = new ActiveXObject("ADODB.Connection"); var adoRS = new ActiveXObject("ADODB.Recordset"); var rec = new ActiveXObject("ADODB.Record"); adoConn.Open="DRIVER={MySQL ODBC 3.51 Driver};SERVER=172.25.37.145;" + "DATABASE=confluence;UID=root;PASSWORD=somePassword;OPTION=3"; //Connectionstring alert('Database Connected'); adoConn.Execute("insert into `session` (SessionId,Timestamp) values ('"+SessionId+"','"+SessionCurrenttime+"')");
如果我获得相同的会话ID,则查询未执行,因为它是数据库中的主键.
完整,这是完整的结构
try { // your code that can throw exception goes here } catch(e) { //do stuff with the exception } finally { //regardless if it worked or not, do stuff here (cleanup?) }