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]
Related
I make a connection for connect to the Database Server (other machine).
Then I found "An error was encountered performing the requested operation:
IO Error: The Network Adapter could not establish the connection
Vendor code 17002".
Please look the picture in URL below.
I tried to make a connection but can't access but my team can access it.
My friend used TNS connection type and I did everthing similar him but can't access. I tried to use JDBC thin for connect but can't also.
I had the old connection which I can connect but why I can't connect the new connection.
You're trying to connect to a machine on a network that SQL Developer is unable to reach.
For a TNS connection,
Look at the appropriate TNSNames entry (you will have a tnsnames.ora) file, and find the IP address or network name associated with the connection you're trying to establish -
And then start by trying to ping that resource.
In this case, i'm trying to talk to a database on MY machine, on port 1521. Yours should look quite different.
If you're using a basic connection, then you can look at the connection properties and see what machine/port you're trying to communicate with.
Ping
If you can't reach that machine from your machine, there's zero chance you can connect to a database there.
So, always start with a ping.
Once you see that you can get to that machine, if you're still getting that message, the next thing to think about is blocked ports, the listener defaults to port 1521, but you'll see that in the TNS descriptor as well.
It usually happens when a another process is running on the same port or there is an absence of listener.
Go to Run>services.msc>OracleXETNSListener>Start
Try to reconnect.. Even if the error still prevail then go to cmd
Use code:
npx kill-port <portnumber>
The port number by default is 1521, but you can check the port number in database properties.
It is possible, that your connection is forbidden by the firewall -
go to Control Panel\System and Security\Windows Defender Firewall - Advanced - Outbound Rules - Add a rule. (If you have some antivirus firewall, add rules there)
Create a temporary TCP rule for your port and another rule for UDP. Allow all nets and comps.
Check the telnet connection as cmd -> telnet ->
open remote.host.address PortNumber
If you can connect now, then the problem IS in firewall - edit your new rules, setting the hosts and nets exactly.
This error is because your sqldeveloper is not able to reach the database server's sql service.
One reason could be lsnrctl is down for some reason.
If you have access to machine where database is installed.
In Windows machine, follow: https://www.youtube.com/watch?v=r9pHqOfV2f0&ab_channel=TLinaTutorials
In Linux/macOS machine: Go to $ORACLE_HOME/bin and check status of lsnrctl
execute from $ORACLE_HOME/bin lsnrctl status, if it's down. Then restart it by lsnrctl start.
Check the details of connection in command output like SID, PORT, HOST etc. and try connecting again from sqldeveloper.
I have a machine(A) that has access to the host running the Oracle listener. I can connect to it fine using SQL Developer.
I have another machine(B) that I would also like to make a connection to the same database but its doesn't have direct access to the host running the listener. However, it does have access to machine (A).
I would like to forward a port on machine A to the Oracle listener host which is listening on port 1521.
Then I should be able to make a database connection from machine B to machine A and then forward a port to the host that has the Oracle listener. Sort of a man in the middle.
However, I'm running into issues. I can't even connect to the Oracle database from machine B using the forwarded port. I have experience using ssh tunnels to do the same thing. In this case, I'm not using ssh and I don't understand why this will not work.
Below is the procedure I'm going through:
Log into machine B - Oracle client is installed. SQL Developer is installed.
Open SQL Developer - Select TNS connection. Enter in credentials. Connection Successful
TNS Names entry:
CRYSTAL=(DESCRIPTION=(ADDRESS_LIST=(LOAD_BALANCE=yes)(FAILOVER=ON)(ADDRESS=(PROTOCOL=TCP)(HOST=testhost.com)(PORT=1521)))(CONNECT_DATA=(service_name=svc1)))
Now setup forwarding:
C:\Windows\system32>netsh interface portproxy add v4tov4 listenaddress=127.0.0.1
listenport=1521 connectaddress=testhost.com connectport=1521
protocol=tcp
If I telnet localhost 1521 , it is able to make a connection.
As a simple test, I make sure I can connect on Machine B using SQL Developer. But this time, I set the connection type to advanced so I can enter the jdbc url.Note, I use 127.0.01 instead of testhost.com because it will be forwarded to testhost.com
jdbc:oracle:thin:#(DESCRIPTION=(ADDRESS_LIST=(LOAD_BALANCE=yes)(FAILOVER=ON)(ADDRESS=(PROTOCOL=TCP)(HOST=127.0.0.1)(PORT=1521)))(CONNECT_DATA=(service_name=svc1)))
This connection fails with "ORA-12516, TNS: listener could not find available handler with matching protocol stack"
I've checked for firewall issues and made sure port 1521 is open.
Any ideas what I might be missing or has anyone else had success forwarding a port to an Oracle listener?
Thanks to the comment from psaraj12, I knew my approach should work. The problem I was having was due to the host name I was given to connect to the database. It works fine if you enter it into SQL Developer as is. However, when I used it in the port forwarding, I could not connect to the database using SQL Developer using the host name localhost. The host name I was given had "scan" in the name. I think this is a Virtual IP. We use Oracle RAC which is a clustering technology. So I suspected to that the VIP selected a node on the cluster and the forwarder could not handle it. So this is how I solved the problem:
Installed Wireshark.
Start recording packets.
Used SQL Developer To Connect with the VIP - Success
In Wireshark, find the TCP Stream that contains something unique about the connection. In this case, the Oracle service name. You should see the IP of the VIP. Something like:
.........6.,.A ...O........:..............................(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=11.3.68.171)(PORT=1521))(CONNECT_DATA=(CID=(PROGRAM=SQL Developer)(HOST=jdbc)(USER=adpc))(SERVICE_NAME=svc1)(CID=(PROGRAM=SQL Developer)(HOST=jdbc)(USER=adpc)))).................6.,.A ...O........:..............................(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=11.3.68.171)(PORT=1521))(CONNECT_DATA=(CID=(PROGRAM=SQL Developer)(HOST=jdbc)(USER=adpc))(SERVICE_NAME=svc1)(CID=(PROGRAM=SQL Developer)(HOST=jdbc)(USER=adpc)))). .......6.A ........ ..........................
Now, go back to the packet and find out what the "real" address is. Here is an example:
Wire shark packet information. This is the destination IP where Oracle listener is.
Now use this to forward the port.
netsh interface portproxy add v4tov4 listenport=1521 connect address=11.3.68.135 connectport=1521 protocol=tcp
Now, when you log in using SQL Developer Basic Connection Type, you can use localhost instead of the VIP and you should be able to connect.
Now, go to another machine that has access to the machine you just set up and you should be able to connect to the database from there as well using the IP of the machine where you have port forwarding setup.
The same forward connection is working fine in both basic and advanced connection in SQL developer in my machine.
The only difference is machine A,B and Database are in the same network in my case where B can directly connect to the database also
Steps
1)You have to set up forwarding in machine A with machine A ip address as the listen address
2) Use the machine A ipaddress in TNS to connect to Database in machine B
If still, you are facing problems then you can try enabling log and trace files to identify the issue as mentioned in these articles
Oracle Database 10g Debugging Connection problems 1
Oracle Database 10g Debugging Connection problems 2
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 created a java program that uses MySql. Now I want to give the app to someone else, and I'm using the URL as: jdbc:mysql://ipAddress:3306/tableName, but it doesn't work, showing the error of connection failure.
What should I do?
It's a troubleshooting stuff, do the following.
Check the Firewall and Port access on MySQL Server computer.
Check the MySQL Service and the DB User is doing good.
Follow the following thread
How to allow remote connection to mysql
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.