I've struggled most of the day today to get the tableChanged() event to fire for a JTable I created to link to a database table, and wanted to share my solution.
As the linked video shows, after creating a custom listener that implements TableModelListener, and adding the listener to the table model object, the listener refused to fire.
Long story short, the answer turned out to be that I had failed to provide a name for the Default elements binding object. (See screenshot immediately below)
Here is a video of me demonstrating this phenomenon more thoroughly. I hope you find it instructive.
Saturday, April 30, 2016
Wednesday, April 27, 2016
SQL Server: T-SQL JOB to kill sessions with long-running transactions
We have a situation in a build/test server in which the application server (jboss, in this case) is unceremoniously killed by the build process.
Because SQL Server has no server side lock, transaction, or query timeout, I developed this job to simulate a 10 minute transaction timeout.
It's not sophisticated, but it will give you a good starting point in case you should have to create your own .
if not exists (select * from sys.schemas where name = 'LOGSCHEMA')
EXEC ('CREATE SCHEMA [LOGSCHEMA] AUTHORIZATION [dbo]')
GO
if exists (select * from sys.tables where name = '#OLD_SPIDS')/* NOTE: In the following, I fully qualified the Kill_Long_Running_tran_log table as dbname.schema.tablename. DB_NAME will need to be changed */
EXEC ('DROP TABLE #OLD_SPIDS')
GO
if not exists (select * from sys.tables where name = 'Kill_Long_Running_tran_Log')
EXEC ('CREATE TABLE [/*change db_name */DB_NAME].[LOGSCHEMA].[Kill_Long_Running_tran_Log] (msg_timestamp datetime2(7), msg varchar(256))')
DECLARE @session_to_kill int = 0
DECLARE @kill_session_statement nvarchar(max)
select dtst.session_id
, dtst.transaction_id
, dtat.name
, dtat.transaction_begin_time
INTO #OLD_SPIDS
from sys.dm_tran_session_transactions dtst
join sys.dm_tran_active_transactions dtat
on dtst.transaction_id = dtat.transaction_id
where dtat.transaction_begin_time < DATEADD(MINUTE,-10,current_timestamp)
select @session_to_kill = session_id
from #OLD_SPIDS
where transaction_begin_time = (select min(transaction_begin_time) from #OLD_SPIDS )
select @kill_session_statement = 'kill ' + cast(@session_to_kill as varchar(10))
if (@session_to_kill != 0)
begin
insert into [LOGSCHEMA].[Kill_Long_Running_tran_Log]
values (current_timestamp, @kill_session_statement)
exec (@kill_session_statement)
end
DROP TABLE #OLD_SPIDS
Subscribe to:
Posts (Atom)
The Database is not accessible after creating Always On Availability Group
Having created a fully functional SQL Server Always On Availability Group, I connect using SSMS. Upon trying to expand the database, I get ...
-
Most of what we're going to want to look at when you're having production issues are available through DMV's. If granti...
-
BibleGateway.com - Passage Lookup: John 10:7, 9-10 9I am the gate; whoever enters through me will be saved.[a] He will come in and go out, a...
-
I spent a lot of time on this one, and it wasn't clear from examples precisely how the various items should be used together. The form...