M
Michael Powe
Hello,
I've written a small GUI application that connects to an ODBC DSN and
retrieves data from the specified database. The GUI then displays the
data in the ResultSet in a JTable.
This works fine the first time the "query" button is clicked. A
subsequent attempt to requery the DB results in a SQLException with
the message (returned from the ODBC driver that is connecting to the
DB):
"Failed to connect to database using this connection string:
[ ... connect string here ... ]
Reason: CoInitialize has not been called"
From research, it appears that CoInitialize is required when more than
one thread accesses an MS database from the application. But, I'm
darned if I can figure out how to find or kill an existing open thread
connection. Calling close() on either the Connection or the Statement
objects just results in a NullPointerException, which indicates to me
that they already are null.
The "query" button executes a SwingWorker thread to open the
connection, make the ResultSet and return the JTable in the
construct() method. The JTable is then displayed (added to a
JScrollPane) in the finished() method.
I sure would appreciate any help.
Thanks.
mp
I've written a small GUI application that connects to an ODBC DSN and
retrieves data from the specified database. The GUI then displays the
data in the ResultSet in a JTable.
This works fine the first time the "query" button is clicked. A
subsequent attempt to requery the DB results in a SQLException with
the message (returned from the ODBC driver that is connecting to the
DB):
"Failed to connect to database using this connection string:
[ ... connect string here ... ]
Reason: CoInitialize has not been called"
From research, it appears that CoInitialize is required when more than
one thread accesses an MS database from the application. But, I'm
darned if I can figure out how to find or kill an existing open thread
connection. Calling close() on either the Connection or the Statement
objects just results in a NullPointerException, which indicates to me
that they already are null.
The "query" button executes a SwingWorker thread to open the
connection, make the ResultSet and return the JTable in the
construct() method. The JTable is then displayed (added to a
JScrollPane) in the finished() method.
I sure would appreciate any help.
Thanks.
mp