java


Connecting to external database through telnet


I have a java program that connects to a MS SQL database. The program works perfectly when running through eclipse however I get an error when I run it through AIX:
java.sql.SQLException: Network error IOException: A remote host refused an attempted connect operation.
I can successfully ping the server but am not able to telnet into the server. I am also not able to telnet from my windows desktop.
I am using jtds to connect:
String connectionString = "jdbc:jtds:sqlserver://"+dropez_ip_address+"/"+dropez_db_name;
ResultSet rs = null;
Statement stmt = null;
try{
Class.forName("net.sourceforge.jtds.jdbc.Driver");
Connection conn = DriverManager.getConnection(connectionString, dropez_db_username, dropez_db_password);
stmt = conn.createStatement();
}catch(Exception e){}
Here is some documentation from jTDS regarding the issue, but I am still not able to resolve the issue.
Why do I get java.sql.SQLException: "Network error IOException: Connection refused: connect" when trying to get a connection?
The "Connection refused" exception is thrown by jTDS when it is unable to connect to the server. There may be a number of reasons why this could happen:
- The server name is misspelled or the port number is incorrect.
- SQL Server is not configured to use TCP/IP. Either enable TCP/IP from SQL Server's Network Utility app or have jTDS connect via named pipes (see the URL format for information on how to do this).
- There is a firewall blocking port 1433 on the server.
To check whether TCP/IP is enabled and the port is not blocked you can use "telnet 1433". Until telnet doesn't connect, jTDS won't either. If you can't figure out why, ask your network administrator for help.
Your SQL Server database probably doesn't have the TCP/IP protocol enabled, to enable it:
From the Microsoft SQL Server 2005 -> Configuration Tools, open the 'Microsoft SQL Server Configuration Manager'.
Expand ‘SQL Server 2005 Network Configuration’, and then click ‘Protocols for ’.
Right-click ‘TCP/IP’ and then click ‘Enable’. The icon for the protocol will change to show that the protocol is enabled.
For SQL Server 2008:
If you can't telnet on port 1433, you are blocked by a firewall somewhere in the middle between your machine and the server. That's not a java related problem.
May it be that when you say "it runs perfectly under eclipse but not AIX" you are taking about 2 different computers ? If so, the one with eclipse is not firewalled, the one where you deploy your app is blocked.
But again, nothing to do with java. It's a level 3 error (TCP layer) of TCP-IP model.
Regards,
Stéphane

Related Links

error in android studio NullPointerException ComponentInfo
Re-introduced “Unknown initial character set index” error?
Toolbar isn't following into next activity
Invalid image POST request JAVA
Two 16 bit ints to One 32 bit float value
Spring WS with simple input parameters and return type
SdkManager class is not available in latest android SDK
How to insert with JdbcTemplate returning autogenerated id?
How to count multiple string length
How to set connection timeout in Camel restlet using spring dsl
int array of Images implementing Picasso
How to inject into an interceptor?
How does JNI works in java? [on hold]
Inject a jar file in another jar file
How to #inject class in jersey hk2 factory in java?
Arquivo .jasper [on hold]

Categories

HOME
ionic-framework
office365api
graphql
jgroups
angular-ui-bootstrap
ezpublish
webrequest
gorm
fancybox-3
imacros
numeral.js
foselasticabundle
pugjs
reactive-cocoa
grails3
autocad-plugin
csrf-protection
bootstrap-tour
wijmo
crosstab
pingfederate
kendo-datasource
gsmcomm
preg-match
xquery-3.0
catel
stacked
espeak
eigenvalue
.net-4.6.2
qcombobox
angular-resource
react-scripts
qsslsocket
veracode
lowpass-filter
lift-json
django-scheduler
pintos
messenger
word-vba-mac
probability-density
pagerank
independentsoft
srand
lemon
python-3.2
deis
sonarqube5.1.2
proj4js
tablelayout
tt-news
google-style-guide
file-copying
gulp-less
html-helper
onactivityresult
android-radiobutton
undefined-reference
dexterity
bulkloader
seed
specification-pattern
itmstransporter
unc
funscript
google-email-migration
gdata-api
code-cleanup
coredump
appender
iphone-web-app
createwindow
dmx512
xsdobjectgen
database-management
compiler-specific
uimenucontroller
scripting-languages
private-members

Resources

Database Users
RDBMS discuss
Database Dev&Adm
javascript
java
csharp
php
android
javascript
java
csharp
php
python
android
jquery
ruby
ios
html
Mobile App
Mobile App
Mobile App