I'm working on a project and I have a java program that parses a bunch of files and breaks them into records which are to be stored within a database. I've tested the program on my own server using the following (intellij generated) string:
And the above string works fine in the code and all the data is stored
But when I try to connect to the (external) project database located at 104.131.96.199 using the following
(There are two open ports: 22 and 80)
On port 80 it hangs on "connecting to database" forever (over 10 mins),
and on port 22 I get the packet size error above.
I've gone into phpmyadmin and changed the max_allowed_packet variable to 4739923, but still get the same issue (the change still isn't reflected in the error).
I'm not in charge of this db, although I have the admin user and pass.
Any help in the matter would be greatly appreciated
I guess I have 2 questions:
Is my connection string syntactically correct (and if not what should it be)
If the string is correct, what to do about the packet size issue / hanging forever
1.) Yes, the URL is syntactically correct. If you want to specify a user and password, you can add ?user=<username>&password=<password> to the end of the String.
2.) It most likely doesnt work because you are apparently using the SSH port (22) and the HTTP port (80) instead of the MySQL port (3306). If these are the only two open ports you will have to ask the server admin to manually allow remote connections to his MySQL server
Syntax is correct.
packet size issue - The changes to max_allowed_packet have possibly not taken effect. Run the below to check the value:
SHOW VARIABLES LIKE 'max_allowed_packet';
hanging forever - Check that the port used is correct.
Related
I am new to Oracle, and am trying to run a simple example code with Java, but am getting this error when executing the code.. I am able to start up the listener via CMD and am also able to run SQL Plus. Can anyone give me a hand and tell me what I might be doing wrong?
Update:
I am using JDBC.
Database is local, and I actually had it working but it stopped working just today. I'm not really sure why though. Would you mind giving me some procedures to follow by since I don't know much.
Either:
The database isn't running
You got the URL wrong
There is a firewall in the way.
(This strange error message is produced by Oracle's JDBC driver when it can't connect to the database server. 'Network adapter' appears to refer to some component of their code, which isn't very useful. Real network adapters (NICs) don't establish connections at all: TCP protocol stacks do that. It would have been a lot more useful if they had just let the original ConnectException be thrown, or at least used its error message and let it appear in the stack trace.)
I had the same problem, and this is how I fixed it.
I was using the wrong port for my connection.
private final String DB_URL = "jdbc:oracle:thin:#localhost:1521:orcll"; // 1521 my wrong port
go to your localhost
(my localhost address) : https://localhost:1158/em
login
user name
password
connect as --> normal
Below 'General' click on LISTENER_localhost
look at you port number
Net Address (ADDRESS=(PROTOCOL=TCP)(HOST=localhost)(PORT=1522))
Connect to port 1522
Edit you connection
change port 1521 to 1522.
done
Another thing you might want to check that the listener.ora file matches the way you are trying to connect to the DB. If you were connecting via a localhost reference and your listener.ora file got changed from:
HOST = localhost
to
HOST = 192.168.XX.XX
then this can cause the error that you had unless you update your hosts file to accommodate for this. Someone might have made this change to allow for remote connections to the DB from other machines.
I figured out that in my case, my database was in different subnet than the subnet from where i was trying to access the db.
I had this error when i renamed the pc in the windows-properties. The pc-name must be updated in the listener.ora-file
Most probably you have listener configured wrongly, the hostname you specify in connection string must be the same as in the listener.
First check the Firewall and network related issues.
Check if Oracle Listener service is available and running. If not you may use Oracle Net Configuration Assistant tool to add and register new listener.
If the above steps are ok then you need to configure Oracle Listener appropriately. You may use Oracle Net Manager tool or edit “%ORACLE_HOME%\network\admin\listener.ora” file manually.
There are 2 options that need to be considered carefully:
Listening Locations associated with the Listener – Hostname(IP) and Port in Listening Location must exactly match the ones used in the connection string.
For example, if you use 192.168.74.139 as target hostname, then there must be Listening Location registered with the same IP address.
Also make sure the you use the same SID as indicated in Database Service associated with the Listener.
https://adhoctuts.com/fix-oracle-io-error-the-network-adapter-could-not-establish-the-connection-error/
IO Error: The Network Adapter could not establish the connection (CONNECTION_ID=iKQM6lBbSLiArrYuDqud8A==)
if you are facing this issue
1- make sure you have downloaded oracle databases like oracle 11g,19c, 21c, or any latest databases.
2- search for services in your computer or type win+r then services.mis then search for oracleservice you will find orcl or xe or any other sid like oracleserviceorcl;
after that you can test your connection using sql developer, sql plus or cmd
To resolve the Network Adapter Error I had to remove the - in the name of the computer name.
In my case, I needed to specify a viahost and viauser. Worth trying if you're in a complex system. :)
For me the basic oracle only was not installed. Please ensure you have oracle installed and then try checking host and port.
I was having issues with this as well. I was using the jdbc connection string to connect to the database. The hostname was incorrectly configured in the string. I am using Mac, and the same string was being used on Windows machines without an issue. On my connection string, I had to make sure that I had the full url with the appending "organizationname.com" to the end of the hostname.
Hope this helps.
Just try to re-create connection. In my situation one of jdbc connection stopped working for no reason. From console sqlplus was working ok.
It took me 2 hours to realize that If i create the same connection - it works.
I am new to Oracle, and am trying to run a simple example code with Java, but am getting this error when executing the code.. I am able to start up the listener via CMD and am also able to run SQL Plus. Can anyone give me a hand and tell me what I might be doing wrong?
Update:
I am using JDBC.
Database is local, and I actually had it working but it stopped working just today. I'm not really sure why though. Would you mind giving me some procedures to follow by since I don't know much.
Either:
The database isn't running
You got the URL wrong
There is a firewall in the way.
(This strange error message is produced by Oracle's JDBC driver when it can't connect to the database server. 'Network adapter' appears to refer to some component of their code, which isn't very useful. Real network adapters (NICs) don't establish connections at all: TCP protocol stacks do that. It would have been a lot more useful if they had just let the original ConnectException be thrown, or at least used its error message and let it appear in the stack trace.)
I had the same problem, and this is how I fixed it.
I was using the wrong port for my connection.
private final String DB_URL = "jdbc:oracle:thin:#localhost:1521:orcll"; // 1521 my wrong port
go to your localhost
(my localhost address) : https://localhost:1158/em
login
user name
password
connect as --> normal
Below 'General' click on LISTENER_localhost
look at you port number
Net Address (ADDRESS=(PROTOCOL=TCP)(HOST=localhost)(PORT=1522))
Connect to port 1522
Edit you connection
change port 1521 to 1522.
done
Another thing you might want to check that the listener.ora file matches the way you are trying to connect to the DB. If you were connecting via a localhost reference and your listener.ora file got changed from:
HOST = localhost
to
HOST = 192.168.XX.XX
then this can cause the error that you had unless you update your hosts file to accommodate for this. Someone might have made this change to allow for remote connections to the DB from other machines.
I figured out that in my case, my database was in different subnet than the subnet from where i was trying to access the db.
I had this error when i renamed the pc in the windows-properties. The pc-name must be updated in the listener.ora-file
Most probably you have listener configured wrongly, the hostname you specify in connection string must be the same as in the listener.
First check the Firewall and network related issues.
Check if Oracle Listener service is available and running. If not you may use Oracle Net Configuration Assistant tool to add and register new listener.
If the above steps are ok then you need to configure Oracle Listener appropriately. You may use Oracle Net Manager tool or edit “%ORACLE_HOME%\network\admin\listener.ora” file manually.
There are 2 options that need to be considered carefully:
Listening Locations associated with the Listener – Hostname(IP) and Port in Listening Location must exactly match the ones used in the connection string.
For example, if you use 192.168.74.139 as target hostname, then there must be Listening Location registered with the same IP address.
Also make sure the you use the same SID as indicated in Database Service associated with the Listener.
https://adhoctuts.com/fix-oracle-io-error-the-network-adapter-could-not-establish-the-connection-error/
IO Error: The Network Adapter could not establish the connection (CONNECTION_ID=iKQM6lBbSLiArrYuDqud8A==)
if you are facing this issue
1- make sure you have downloaded oracle databases like oracle 11g,19c, 21c, or any latest databases.
2- search for services in your computer or type win+r then services.mis then search for oracleservice you will find orcl or xe or any other sid like oracleserviceorcl;
after that you can test your connection using sql developer, sql plus or cmd
To resolve the Network Adapter Error I had to remove the - in the name of the computer name.
In my case, I needed to specify a viahost and viauser. Worth trying if you're in a complex system. :)
For me the basic oracle only was not installed. Please ensure you have oracle installed and then try checking host and port.
I was having issues with this as well. I was using the jdbc connection string to connect to the database. The hostname was incorrectly configured in the string. I am using Mac, and the same string was being used on Windows machines without an issue. On my connection string, I had to make sure that I had the full url with the appending "organizationname.com" to the end of the hostname.
Hope this helps.
Just try to re-create connection. In my situation one of jdbc connection stopped working for no reason. From console sqlplus was working ok.
It took me 2 hours to realize that If i create the same connection - it works.
I'm creating a java application that connects to a Firebird database and retrieve some data. The program is done, and it runs well in my computer. The problem is that, in the computer I need to run the application, the database is in another computer in the local network and I have no idea of which path should I put into the connection string of jaybird to get it running. Let me explain a bit:
I need to run my application in a computer X, but the actual database is not in a drive in the computer, but in a computer in the local network. Something like this (this is an example, and its reproduced at my home, not at the actual site I need to get it to work):
So the path that it gives me for the database is something like:
I know that if my database is in my drive ( for example, in C:\Users\john\Desktop ), my connection to the database using Jaybird should be something like this:
static final String FB_DB_URL = "jdbc:firebirdsql://localhost:3050/C:\\Users\\john\\Desktop\\TEST1.FDB";
FB_connection = DriverManager.getConnection( FB_DB_URL , FB_USER , FB_PASS);
Actually, that is how I managed to make it work in my computer. But in this case I have no clue of how should the path be. I tried something like:
static final String FB_DB_URL = "jdbc:firebirdsql://192.168.0.101:3050/\\\\DESKTOP-1UFA09I\\Documents\\TEST1.FDB";
With ‘192.168.0.101’ being the ipv4 address of the computer where the database is. But this gave me an exception saying that the application was unable to find the database. I think this is the closest I was to find the solution, but I had no luck.
Some extra information:
Both computers had the firewall off, and could send ping to each other, so they are, in fact, connected.
I'm using Firebird 2.5 and jaybird 2.2.1.
I also tried the following with no luck:
static final String FB_DB_URL = "jdbc:firebirdsql://192.168.0.101:3050/C:\\users\\john2\\Documents\\TEST1.FDB";
The folder is shared (or at least, that’s what I think) because I can get access to it via windows, and the database file gives read/write permissions to everyone.
I'm sure that Firebird is running in both PCs.
Any help in the matter would be greatly appreciated. I'm sure the problem is in the path, because, as I said, the application works well in with the database in my computer. Also, if you could give me a solution that doesn’t require the IP of the computer where the DB is stored that would be awesome, but I think I can get that information anyways.
EDIT
For documenting purposes the solution to the problem was the following:
the right way of making the path to the database is:
"jdbc:firebirdsql://192.168.0.101:3050/C:\\folder1\\folder2\\TEST1.FDB";
the exception occurred because, apparently, jaybird has some permission issues with the users folder in the server. As my DB was located in the documents folder, it was causing some problems when jaybird tried to get access to it. the solution is to move the DB to another folder in C://
To connect to a remote database you need to know the following things:
The hostname or IP address of the Firebird server
The port number of the Firebird server (default 3050)
User name and password
Alias of the database or the full path of the database
You seem to have the first three items covered, so the problem is with the fourth. You think the database is located in C:\users\john2\Documents\TEST1.FDB. If that is the case, then the JDBC url is:
jdbc:firebirdsql://192.168.0.101:3050/C:\\users\\john2\\Documents\\TEST1.FDB
However, the user running the Firebird server process by default has no access to user folders for security reasons.
I suggest that you move the database to a location outside of the user folder, and make sure the account running the Firebird server service has read and write access (NETWORK SERVICE or LOCAL SYSTEM, I forgot which and I currently don't have access to Windows machine) .
Other notes:
Locations of a Firebird database should not be shared, because accessing a database remotely should be done through a Firebird server
You should really update to Jaybird 2.2.11; 2.2.1 is almost 4 years old and a lot has been fixed since
If you are really using Firebird 2.5(.0), then upgrade to 2.5.6, or consider upgrading to 3.0
It looks like you want to connect to the Firebird server in a client/server mode and pass the filename of the database to it. The "host:port" part connects to the server, what follows the next "/" is the name of the database file.
If you use 192.168.0.101:3050 you have to make sure the server runs on the other machine having the IP 192.168.0.101. Since the server is already on the other machine, you need to give it local name of the database name on that machine, like in
static final String FB_DB_URL = "jdbc:firebirdsql://192.168.0.101:3050/C:\\users\\john2\\Documents\\TEST1.FDB";
To not use the IP you'd need to give that machine a name that can be DNS resolved in the local network, which is not difficult, an entry in the hosts name would suffice. The port 3050 is actually the default port so you can omit it.
Since this doesn't work I guess the server is not running on the target machine, only the database file is there. In this case you should connect to you local server but let it know the network reachable database file name, like in
static final String FB_DB_URL = "jdbc:firebirdsql://localhost/\\\\DESKTOP-1UFA09I\\Documents\\TEST1.FDB";
It should allow the local Firebird server to open the \\DESKTOP-1UFA09I\Documents\TEST1.FDB file over the local network - of course if the network share DESKTOP-1UFA09I points to the right location and the account under which the local Firebird server has sufficient access rights on the other machine.
I have a Java (Swing) desktop connected to a godaddy MySQL database (online database). Till the time database was offline, this was not at all the problem, but now I get this exception when I try to access some menu which involves a database access.
Also, I create a static connection object when my application start, and never close it when the application is running.
This is the description of Exception, please help if you can. Thanks :)
com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link fai
lure
Last packet sent to the server was 47 ms ago.
SOME MORE STACK TRACE AND THEN THE CHAINED CAUSE
Caused by: java.io.EOFException: Can not read response from server. Expected to
read 4 bytes, read 0 bytes before connection was unexpectedly lost.
I am assuming that you are on a shared hosting. Connecting to such a hosting publicly is not advisable.
Dealing with the problem this seems a problem with Remote SQL. There are a few things you can do
1. Go to your cPanel or equivalent and navigate to Remote SQL add the address 0.0.0.0 which will allow connections from any public ip that may want to connect with it. If your are using a vpn like AWS you have to manually edit the my.cnf or my.ini depending on weather you are hosted on linux or windows, add
bind-address = 0.0.0.0
under the
[mysqld]
tag
Next you need to create a user which can be accessed from any ip as root user only has permission to be accessed locally
GRANT ALL ON yourdatabasename.* TO user#'%' IDENTIFIED BY 'yourRootPassword';
I have a local network connecting 15 PCs. Every PC has postgres installed (8.3, 8.4, 9.2). Every database has the exact same installation parameters as name, user, password, etc.
I'm using a Java application, which implements JDBC library and I have been able to connect correctly to the databases in EVERY computer but one. I'm pretty sure I have set correctly the necesary parameters for pg_hba.conf and postgresql.conf, because they are set the same in all the 15 PCs.
I also have set the Windows Firewall exception for the port 5432
All this has lead me to conclude that the problem lies in that specific PC that doesn't accepts the connection. It has Windows 7 Ultimate installed, the same as the rest, and postgres 8.3.
This is the error that i get: org.postgresql.util.PSQLException: Connection attempt timed out.
I don't want to format the PC from zero
Can someone help me with this?
Well, now I know how to solve the problem with a not very orthodox solution. When this happens, we just copy the pg_hba.conf from a working PC and this solves the problem. I hope this helps.