Swing application framework and SQL-connection in initialize method
I have a strange problem with java and SAF. I'm using Netbeans and SAF for month and until last week, everything worked fine. But suddently my sql connections doesn't work very well.
Here is my code:
This code has worked for month with no problems. I'm using this code in several programs. But suddently in all of my programs, the connection to the database cannot be established. The program get stucked in the Drivermanager at following line "Connection result = di.driver.connect(url, info);" After 30min I get the exception "connection refused"
public static void main(String args)
protected void initialize(String args)
SAXBuilder builder = new SAXBuilder();
Document doc = builder.build(new File(CONFIG_FILE));
Element root = doc.getRootElement();
String server = root.getChildText(SERVER);
String database = root.getChildText(DATABASE);
_con = DriverManager.getConnection("jdbc:jtds:sqlserver://" + server + "/" + database, _user, _password);
_server = server;
catch (Exception ex)
JOptionPane.showMessageDialog(null, ex.getMessage(), "Error", JOptionPane.ERROR_MESSAGE);
The strange thing is, if i use localhost everthing works fine again. If I initialize a SQL-connection (with another Connection var) to any database in the main-method (and directly close it), the above connection in initialize also works fine again.
I tried to use Wireshark. No packages were send over the network. So I guess, there is no problem at the server or network. My program stucks in DriverManager and no package is sent. On the other side, this code worked for month in several programs with no problems, so I cannot see any error in the code. My programs are installed on several machines and connects to several databases. My strange problem occoured over night on all programs and all databases.
I hope anybody can help me.