My java web application connects to remote MSSQL server database by using JDBC. The address is a web URL: https://mssql2008.server.com. It works well on my PC. However, after I deployed it to Tomcat 9 on VPS CentOS 7. I got an error as follows:
com.company.app.utils.DBConnection. nullcom.microsoft.sqlserver.jdbc.SQLServerException: The TCP/IP connection to the host mssql2008.server.com, port 1433 has failed. Error: "mssql2008.server.com. Verify the connection properties. Make sure that an instance of SQL Server is running on the host and accepting TCP/IP connections at the port. Make sure that TCP connections to the port are not blocked by a firewall.".
I have checked my MSSQL server and the port is opened and I can connect from my PC with only URL (without port). I also used PHP app on VPS for trying to connect but it also fails by login timeout ERROR
SQLSTATE[HYT00]: [unixODBC][Microsoft][ODBC Driver 13 for SQL Server]Login timeout expired
Is there anyone knows what happens? I think the problem is raised from my VSP CentOS. Do I need to install anything more on my VPS to let it can connect to MSSQL? or Is this a firewall problem?
Thank you in advance,
Related
I am trying to start H2 in server mode to connect an application from another computer. But no matter how hard I have tried, I have not succeeded.
I have seen the documentation and to start the server from the command line is executed:
java -cp h2-2.1.214.jar org.h2.tools.Server -tcpAllowOthers
output:
TCP server running at tcp://127.0.1.1:9092 (others can connect)
PG server running at pg://127.0.1.1:5435 (only local connections)
Web Console server running at https://127.0.1.1:8082 (others can connect)
now from the other pc, as I understand I must execute the connection in the following way:
jdbc:h2:tcp://[server][:port]/[path]/[databaseName]
then it should be:
jdbc:h2:tcp://127.0.1.1:9092/home/mateo/database
But I have read that 127.0.1.1 only works locally. I have also noticed that when I open H2 Console in the examples I have seen, the machine's ip appears, that is to say: 192.168.X.
What am I doing wrong?
(Update)
I am currently using Linux.
I have launched the server from Windows and managed to connect it from Linux successfully following the above steps. But, I still don't understand why it doesn't work in Linux, in Windows it loads the server with the IP address of the machine. It makes me think that I have to do some additional configuration for Linux.
server running
You need to replace local IP address in your JDBC URL with real non-local IP address of your server (jdbc:h2:tcp://127.0.1.1:9092/*** -> jdbc:h2:tcp://192.168.1.4:9092/***, for example). H2 listens all network interfaces of the host, it doesn't matter which address was reported in “runnig at …” message.
You also may need to protect ports 8082 and 9092 from connections from untrusted systems if you have them in your internal network and from connections from external network (make sure your router or whatever you have doesn't redirect connections to the host with database server).
I am learning SQL/SQL Server 2012. I am also learning how to make forms with java using NetBeans. I am trying to link java to my SQL Server 2012 Express so I can make a form that uses/updates data in a SQL database but have not been successful.
I have done lots of research trying to find a solution and made changes that I found I needed to make. I have set up SQL Server to use TCP port 1433 on my computer. I have also made an exception in my firewall to allow that incoming connection. I have created a user "admin" and given that user sysadmin role. I have also set up SQL Server to allow remote connections with a time out of 60 seconds.
When I try to connect to the SQL Server from MS SQL Server Management Studio and put my computers static IP and port 1433, I get the attached error:
When I try to connect to the SQL Server database from NetBeans I get this:
Cannot establish a connection to
jdbc:sqlserver://DEVINSPC\SQLEXPRESS;databaseName=Test using
com.microsoft.sqlserver.jdbc.SQLServerDriver (The TCP/IP connection to
the host DEVINSPC, port 1433 has failed. Error: "connect timed out.
Verify the connection properties. Make sure that an instance of SQL
Server is running on the host and accepting TCP/IP connections at the
port. Make sure that TCP connections to the port are not blocked by a
firewall.".)
I am using jdbc4.2.jar file. I have set SQL Server to use both SQL Server and Windows Authentication. Hopefully this all makes sense.
If you need anymore info let me know. Any help is appreciated!
I am running a project in Eclipse that uses JDBC drivers. However, every time I run it I get the following error:
The TCP/IP connection to the host localhost, port 1433 has failed. Error: "Connection refused: connect. Verify the connection properties. Make sure that an instance of SQL Server is running on the host and accepting TCP/IP connections at the port. Make sure that TCP connections to the port are not blocked by a firewall.".
I am sure that the SQL Server Management Studio is using the 1433 port as well. But I want to verify it. Can someone tell me where do I go to check? I've been playing around with SQL Server for the past one hour and I can't find the slightest clue as to where it is.
Thanks in advanced.
Load up SQL Server configuration manager from start menu and check the network config. as per screenshot: http://tinypic.com/r/2hcgfgg/5
Go to start > Programs > Microsoft SQL Server > Configuration Tools > SQL Server Configuration Manager
Expand SQL Native Client 10.0 Configuration. Click Client Protocols. Make sure TCP/IP is enabled. Then double click TCP/IP. The port should be listed under Default Port.
I use the telnet trick to test if I can connect to a port and make sure it's not something else blocking my connection. Open a command prompt from the client and type: telnet hostname 1433
If you get a blank black screen you've connected successfully on port 1433. If you get a connection error then you know the port is blocked somewhere.
I am totally new to MySQL Server but good at Java! I know how to connect with the MySQL Server using Java. Recently, I have made a simple small MySQL Server (Test) app for me. Its just for my knowledge! I have successfully connected to the database and successful to use INSERT and SELECT Statements in my Java App.
The problem is that my app is only running on my that laptop on which the SQL Server 2008R2 is installed on! I just checked my app on my another Laptop and it says the following error:
com.microsoft.sqlserver.jdbc.SQLServerException: The TCP/IP
connection to the host localhost, port 1433 has failed. Error:
"Connection refused: connect. Verify the connection properties.
Make sure that an instance of SQL Server is running on the host
and accepting TCP/IP connections at the port. Make sure that TCP
connections to the port are not blocked by a firewall.
I have tried this link so far no Success an still I can't access my Data Base on my other machine!
msdn.microsoft.com/en-us/library/ms175043.aspx
From an answer i also tried my best!
stackoverflow.com/a/12430561/2496503
From this answer i have come to know that my SQL Server Network Configuration(32-bit) is not showing any details/options as mentioned in the above answer here is a snapshot attached herewith !
PLEASE TELL ME IF IT IS ORDINARY THING THAT IT IS NOT SHOWING ANY OPTIONS! ELSE MY SQL SERVER ISN'T INSTALLED CORRECTLY PLEASE HELP ME GIVE ME JUST HINTS I WILL BE THANKFUL TO YOU !
Perform these Steps for TCP/IP network Configuration upto step 6, ur problem will be solved.
[http://www.visual-paradigm.com/support/articles/solve-sql-server-connection-problem.jsp][1]
I'm testing a client-server based Java application where a specific scenario involves having both the client and server running on the same host (i.e., the client connects to the server running on localhost). This seems to work fine except for when I test this scenario on a virtual machine (running 32bit Windows 7) using VirtualBox.
Note: Everything henceforth is running inside the virtual machine. I start the server and try to connect to it using the client but the connection times out. Surprisingly, I tried connecting to the server using putty and the connection behaved as expected. Both the Java client and putty tried to connect to localhost - the client failed but putty succeeded.
Does anyone have a possible explanation for why this might be happening?
Note: This is not a duplicate of Addressing localhost from a virtualbox virtual machine
How do you connect to the localhost? By connecting to the hostname "localhost"? You could try connecting to the InetAddress returned by getLocalHost()