NetBeans Forums
| View previous topic :: View next topic |
| Author |
Message |
dthompson
Joined: 19 Nov 2009 Posts: 21
|
Posted: Tue Dec 06, 2011 6:39 pm Post subject: Database New Connection Wizard Test Connection Not Working |
|
|
JDK 1.7, NetBeans IDE 7.1 RC1, Windows 7 64-bit
I am trying to create a connection to a SQL Server database using the 'New Connection Wizard'. When I run 'Test Connection', I get TCP/IP errors (takes a while for the message to return, like it reached a timeout).
If I use the same driver to connect using the same credentials in my java code, I am able to establish a connection and communicate with SQL Server.
I have tried two different SQL Server drivers, with the same results.
My question is: What is the 'Test Connection' button doing in the wizard? I am trying to understand why my java code can connect to the server, but the wizard cannot. I would like to be able to use the available tools NetBeans has to offer when working with databases. Thanks.
Doug. |
|
| Back to top |
|
 |
dthompson
Joined: 19 Nov 2009 Posts: 21
|
Posted: Mon Dec 19, 2011 8:12 pm Post subject: |
|
|
Still having the same problem. I am able to use Microsoft SQL Server Management Studio, and I can connect to the databases fine -- created and edit tables, etc. However, for some reason, when I attempt to create a database connection in the services tab, I continue to get the same connection error. Is there a problem with NetBeans? As stated, I can connect via the code, but I would like to use a lot of the wizards/tools available that NetBeans has to offer when working with databases. Thanks.
Doug. |
|
| Back to top |
|
 |
Matthias Bl Posted via mailing list.
|
Posted: Wed Dec 21, 2011 9:29 pm Post subject: Database New Connection Wizard Test Connection Not Working |
|
|
Hey,
Am Montag, den 19.12.2011, 20:12 +0000 schrieb dthompson:
| Quote: | However, for some reason, when I attempt to create a database
connection in the services tab, I continue to get the same connection
error.
|
It would be helpfull, if you could provide the complete connection
parameters you supplied (of course without problematic specifics (like
the password)) and the JDBC driver you configured.
Currently I'm mainly using the SQL Server Management Studio, but I
remember having MSSQL Connections in my netbeans instance with the
drivers supplied by microsoft. So it should work.
Check whether you supplied the correct tcp port - I had similar problems
using php and adding the port made it work like a charm.
HTH
Matthias |
|
| Back to top |
|
 |
dthompson
Joined: 19 Nov 2009 Posts: 21
|
Posted: Thu Dec 22, 2011 12:06 am Post subject: |
|
|
The jdbc driver is sqljdbc4.jar.
Using the wizard, after entering the info, here's what the JDBC URL looks like:
jdbc:sqlserver://servername:port#;databaseName=databasename
The user name/password do not show up in the URL field. When I press 'Test Connection', it waits for several seconds then comes back with the error message.
In the code, my url is exactly the same, then I use the DriverManager to get the connection:
| Quote: | String url = jdbc:sqlserver://servername:port#;databaseName=databasename;
Connection con = DriverManager.getConnection(url, username, password); |
And that connection works fine -- only in the wizard am I having trouble. That is why I was wondering what the wizard is doing differently. Thanks for taking a crack at it.
Doug. |
|
| Back to top |
|
 |
Matthias Bläsing Posted via mailing list.
|
Posted: Thu Dec 22, 2011 11:59 am Post subject: Database New Connection Wizard Test Connection Not Working |
|
|
Hey,
On Thu, 22 Dec 2011 00:06:39 +0000, "dthompson" <address-removed>
wrote:
| Quote: | The user name/password do not show up in the URL field. When I press
'Test Connection', it waits for several seconds then comes back with the
error message.
|
I gave it another spin. The jdbc driver is from here (meaning version
3.0):
http://msdn.microsoft.com/en-us/sqlserver/aa937724
it is recognized as "Microsoft SQL Server 2005" by netbeans.
Specifing the correct information (hostname, port (1433) and database) I
get the connection as I would expect.
You can get more information about your error from the IDE Log. When a
connection error occurse the detailed problem is written there (for example
an complete stacktrace can be found there).
So please try again and have a look at the log (Menu => View => IDE Log)
if you can't get to a resolution, please provide the log here.
Greetings
Matthias |
|
| Back to top |
|
 |
dthompson
Joined: 19 Nov 2009 Posts: 21
|
Posted: Thu Dec 22, 2011 5:54 pm Post subject: |
|
|
First of all, this has been very helpful, and I thank you!
After looking at the log per your suggestion, the following helped me identify where to look in the NetBeans code to see what is going on. Here is the snippet from the log (I needed to change db names, etc. before posting):
| Code: | com.microsoft.sqlserver.jdbc.SQLServerException: The TCP/IP connection to the host hostname, port port# has failed. Error: "Connect timed out. Verify the connection properties, check that an instance of SQL Server is running on the host and accepting TCP/IP connections at the port, and that no firewall is blocking TCP connections to the port.".
at com.microsoft.sqlserver.jdbc.SQLServerException.makeFromDriverError(SQLServerException.java:171)
at com.microsoft.sqlserver.jdbc.SQLServerConnection.connectHelper(SQLServerConnection.java:1033)
at com.microsoft.sqlserver.jdbc.SQLServerConnection.login(SQLServerConnection.java:817)
at com.microsoft.sqlserver.jdbc.SQLServerConnection.connect(SQLServerConnection.java:700)
at com.microsoft.sqlserver.jdbc.SQLServerDriver.connect(SQLServerDriver.java:842)
at org.netbeans.modules.db.explorer.DbDriverManager.getConnection(DbDriverManager.java:131)
at org.netbeans.modules.db.explorer.DatabaseConnection.doConnect(DatabaseConnection.java:928)
|
I looked into the org.netbeans.modules.db.explorer.DbDriverManager class, and found that this is where the exception is thrown:
| Code: | public Connection getConnection(String databaseURL,
Properties props, JDBCDriver jdbcDriver)
throws SQLException {
if (LOG) {
LOGGER.log(Level.FINE, "Attempting to connect to \'"
+ databaseURL + "\'"); // NOI18N
}
// try to find a registered driver or use the supplied jdbcDriver
// we'll look ourselves in DriverManager, don't look there
Driver driver = getDriverInternal(databaseURL, jdbcDriver,
false);
if (driver != null) {
--> Connection conn = driver.connect(databaseURL, props); |
Based on the IDE log, it looks like I am using the same driver to connect as the 'getConnection' method. I tried modifying the url and properties to see if I could duplicate the timeout error, but am unable to get the 'Connect timed out' message. I may see if I can uninstall the drivers and start over. Based on the code and what I am doing manually, it still seems to me that they should either both work or both error out.
Doug. |
|
| Back to top |
|
 |
Matthias Bl Posted via mailing list.
|
Posted: Sun Dec 25, 2011 8:30 pm Post subject: Database New Connection Wizard Test Connection Not Working |
|
|
Hey,
Am Donnerstag, den 22.12.2011, 17:54 +0000 schrieb dthompson:
| Quote: | I looked into the org.netbeans.modules.db.explorer.DbDriverManager class, and found that this is where the exception is thrown:
Driver driver = getDriverInternal(databaseURL, jdbcDriver,
false);
if (driver != null) {
--> Connection conn = driver.connect(databaseURL, props);
|
| Quote: | Based on the IDE log, it looks like I am using the same driver to
connect as the 'getConnection' method. I tried modifying the url and
properties to see if I could duplicate the timeout error, but am
unable to get the 'Connect timed out' message. I may see if I can
uninstall the drivers and start over. Based on the code and what I am
doing manually, it still seems to me that they should either both work
or both error out.
|
Your analysis seems resonable. The jdbc driver in netbeans should see
the same network topology as your stand alone example.
First thing, that you could do is usind a debugger with the source code
corresponding to you netbeans installation and check the supplied
databaseURL and props, that netbeans uses. Maybe there are slight
differences.
The second - recheck the configure jdbc driver, that is indeed the same
version as your test project loads.
Third - fire up wireshark and monitor the network connections: Are the
same DNS requests made, are the same connection initiated?
Greetings
Matthias |
|
| Back to top |
|
 |
dthompson
Joined: 19 Nov 2009 Posts: 21
|
Posted: Thu Dec 29, 2011 7:47 pm Post subject: |
|
|
I've been pulled off onto another project as of late, so haven't been able to spend much time on this. I did get Wireshark installed, and was able to capture data from both instances. They do look a little different from what I can tell at first glance. I will look into it a bit further and see if I can narrow it down. Thanks for the tips.
Doug. |
|
| Back to top |
|
 |
dthompson
Joined: 19 Nov 2009 Posts: 21
|
Posted: Wed Jan 04, 2012 3:42 pm Post subject: FIXED!! |
|
|
Well, found a way to get it to work... I was working through a tutorial on creating a module that worked with databases. As I ran the module, which launched the IDE for the RCP, I found I was able to connect to the database! I thought this was odd that it would work in that project but not in the IDE from which it was launched.
Here is the key... after doing a 'clean and build', then launching the app from the IDE, the message
| Quote: | | Settings created by a previous version of the IDE were found on your system at userhome\.netbeans\previous_release Do you want to import them? |
If I say 'Yes', then I get the same error/problem. If I choose 'No', then it works correctly and I can connect to the database.
So... I reinstalled NetBeans (alternatively one could just delete the corresponding settings directory at userhome/.netbeans/). When first launching, after getting asked this question, I chose 'No', and voila, it works!
I have not done any further research to find out what imported setting was causing the problem. Hopefully if anyone else has the issue in the future they can use this for a work-around. I wish I had a root cause -- if I find it, I will certainly post it here...
Vielen dank, Matthias!
Doug. |
|
| Back to top |
|
 |
dthompson
Joined: 19 Nov 2009 Posts: 21
|
Posted: Wed Jan 04, 2012 8:51 pm Post subject: Root Cause Determined |
|
|
I was able to finally determine the root cause to this... it has to do with the proxy settings. I need to use a proxy, so all I did was add the SQL Server host name to the 'No Proxy Hosts' list, and it now works.
Funny how sometimes when you find the solution, it becomes a 'duh' moment... should have looked at this long ago! Oh well, I learned a lot in the process!
Doug. |
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum You can attach files in this forum You can download files in this forum
|
|