I need to allow user to kill queries running in database(i.e Mysql)from our web application. I have gone tghrough some links and I come to know that we can achieve this by killing connection of connection object.
But I am not able to find any method in JDBC connection object API to get connection id of object in Java Docs
Can any one please let me know any way to get the conncetion id of JDBC connection object or is there any other way by which I can achieve the same.
I'm not sure what a "connection ID" is, but what good would it do you? As long as you have a Connection object, you can close it. I'm fairly certain that it would be DB-dependent if the query is aborted at that point, though; some DBs may still execute it until completion.
Consult the documentation of whichever DB you're using; the DB may kill a query if the connection is closed, or you may need to call some system stored procedure, or nothing may work. This is highly DB-specific, and JDBC has no provisions for this.
I have created a sample application in Java and execute the same query from Java manually. I am able to kill the query but in the same program, I have got the connection id using watch of eclipse. The connection id is present in the connection object of JDBC but there is no function available to get the same value from program
You may be able to get at it by casting the Connection to whatever MySQL-specific class/interface implements it; maybe that has methods to get at the ID. Heck, that may even have a method to cancel the last query...
I am not getting your reply. Connection object has property as connection id by the help of which we can kill the query. There is no method available in the connection class to get the value of that property.
Can you please explain it to me by the help of some example that would be very nice of you.
You showed up just in time for the waffles! And this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop