Problem with ODBC Connection from GUI

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top