I have a remote Linux server and I want to connect to an Oracle database which is in another server, using ojdbc7 lib
When I try to connect directly to the database from my Windows PC, using the same client and ojdbc7 lib, I have reasonable connection time.
Now, when I want to connect through my linux server, I get extreme slowness, just in the connection time. . Once connected, the execution is OK.
I have read about adding -Djava.security.egd=file:/dev/urandom like in this post, but nothing happened.
What could I do to fix this delay in setting up a connection from linux?
Close, but no cigar: it's "file:///dev/urandom", or one of the variations, see eg. https://anirban-m.blogspot.com/2014/03/jdbc-connection-reset-error-java.html
I noticed you are using version 12.1.0.1.
There was an Oracle bug where JDBC connections could take excessive times because the data being sent required the listener to perform a DNS lookup for each connection and that could apparently be very slow for some reason.
The bug was fixed in 12.2 and there is a back-ported fix (patch) for 12.1.0.2.
In the meantime, try getting your Linux admin to go through the process of tuning DNS lookups on that server. E.g., tune /etc/resolv.conf or enable the name service cache daemon. I'm not really expert in Linux administration so I can't help you. But based on the problem and the version you are using, that's where I'd look.
I used visualvm last week on my notebook and it worked without any issues. When I wanted to use it yesterday I get the error: VisualVM Cannot connect to 178.xxx.xxx.xxx:xxxx using service:jmx:rmi///... once adding a jmx connection.
The odd thing here is that I have the same version of visualvm, java jdk, java security level, internet connection and windows 7 professional on the desktop computer where it still works.
firewall disabled (didn't work)
port forwarding (not needed as it works fine on the desktop computer with the same connection)
additional firewalls or anti virus software is not present
The notebook is a dell and a few days ago it got a major bios and dell util update, but I don't think this should fall into account in this matter.
Do you have any idea what else it could be, or what else I could do to track down the issue?
FYI I have another WIN7 home computer where it still works and a partner reported that he is getting the same issue for some time now on his desktop and notebook. I'm really at the end of my expertise :(
Seems like network environment issue. You may trace the other port first. (like 80 port)
I'm attempting to get a development environment up and running on my OSX laptop, creating JSPs within Eclipse, running with a Tomcat server, and connecting to an Oracle database.
Eclipse and Tomcat are playing nice together, and I can make JSPs and so forth. The hard part now is getting an Oracle database up and running on Mountain Lion, and getting Eclipse to connect to it.
After extensive Googling, I have found a number of resources:
http://dimitrisli.wordpress.com/2012/08/08/how-to-install-oracle-database-on-mac-os-any-version/
http://barrymcgillin.blogspot.com/2011/12/using-oracle-developer-days-virtualbox.html
(or even https://docs.google.com/document/d/1Th5MSIhS13YIJYCD8W1GLnOQEfrfov-92-He1cluTec/pub)
Following these (rather thorough) guides, I have downloaded the latest Virtual Machine from Oracle, here:
http://www.oracle.com/technetwork/database/enterprise-edition/databaseappdev-vm-161299.html
Note: All three of the above tutorials use a slightly older version of the VM, which has Oracle DB 10 or 11, but the one available now is 12c. The new one also has a different version of Oracle Linux, and probably some other differences. Various usernames and passwords seem to be slightly different.
I installed VirtualBox, loaded in the VM, brought it online. I have the Network settings configured with just a NAT adapter, with the adapter type as "PCnet-FAST III", and port forwarding from 127.0.0.1 to 10.0.4.15 on port 1521 to 1521 and 2222 to 22.
Now, if I open Terminal on my host machine, I can SSH into my VM via: ssh -p 2222 oracle#localhost. I get the Terminal in the VM, and it gives me the same welcome message I get when I first boot up the VM in VirtualBox. Also, I can ping localhost or 127.0.0.1 and it responds with a variable but short lag.
Based on this I can only assume that my VM is working, and that my port forwarding (which is laid out in all 3 of the tutorials I linked to up there) is in good shape.
Now comes the part where I would want to connect Eclipse to the Oracle database that's within the VM. If you look under the first tutorial, dimitrisli sets up IntelliJ with a datasource pointing to the VM. I want to do the same within Eclipse.
I am new to Eclipse, so I looked around for exactly how to do this, and I came up with:
1) Make a new Database Driver.
I downloaded the JDBC for Oracle Database 12c, JDK 7, from Oracle, here. I stuck the .jar file in my Documents folder (in case that's wrong). Within Eclipse I made a new Database Driver, based off one of the other Oracle Driver templates, and changed the settings. Under "Driver Files" I pointed to my ojdbc7.jar file, and under "Properties" I have the following--let me know if this is wrong:
Catalog: USER
Connection URL: jdbc:oracle:thin:#localhost:1521:orcl
Database Name: pdb1
Driver Class: oracle.jdbc.OracleDriver
Password:
User ID:
I tried to use what came in the Oracle Driver template and just tweak to match my exact scenario (based on what was said in the walkthroughs and what I could divine from poking around the modern version of the VM).
2) Make a new Database Connection.
When I go to make a new Database Connection, I go to the Driver Properties area, and I can pick my custom Driver. There is also a Properties field, which I enter the following into: (some of it seems to overwrite or duplicate what I typed in when I made the Driver itself?)
SID: orcl
Host: 127.0.0.1
Port Number: 1521
User Name: hr // Gotten from one of the tutorials. Have also tried 'system/oracle', neither works yet.
Password: oracle
Connection URL: jdbc:oracle:thin:#127.0.0.1:1521:orcl // Immutable, set by the Driver I suppose.
Catalog: User
When I click Test Connection, it hangs for a while and then I get a 'Ping failed!' error, with details:
java.sql.SQLRecoverableException: IO Error: Socket read timed out
at oracle.jdbc.driver.T4CConnection.logon(T4CConnection.java:673)
at oracle.jdbc.driver.PhysicalConnection.<init>(PhysicalConnection.java:715)
at oracle.jdbc.driver.T4CConnection.<init>(T4CConnection.java:385)
at oracle.jdbc.driver.T4CDriverExtension.getConnection(T4CDriverExtension.java:30)
at oracle.jdbc.driver.OracleDriver.connect(OracleDriver.java:564)
at org.eclipse.datatools.connectivity.drivers.jdbc.JDBCConnection.createConnection(JDBCConnection.java:298)
at org.eclipse.datatools.connectivity.DriverConnectionBase.internalCreateConnection(DriverConnectionBase.java:105)
at org.eclipse.datatools.connectivity.DriverConnectionBase.open(DriverConnectionBase.java:54)
at org.eclipse.datatools.connectivity.drivers.jdbc.JDBCConnection.open(JDBCConnection.java:81)
at org.eclipse.datatools.enablement.internal.oracle.JDBCOracleConnectionFactory.createConnection(JDBCOracleConnectionFactory.java:27)
at org.eclipse.datatools.connectivity.internal.ConnectionFactoryProvider.createConnection(ConnectionFactoryProvider.java:83)
at org.eclipse.datatools.connectivity.internal.ConnectionProfile.createConnection(ConnectionProfile.java:359)
at org.eclipse.datatools.connectivity.ui.PingJob.createTestConnection(PingJob.java:76)
at org.eclipse.datatools.connectivity.ui.PingJob.run(PingJob.java:59)
at org.eclipse.core.internal.jobs.Worker.run(Worker.java:53)
Caused by: oracle.net.ns.NetException: Socket read timed out
at oracle.net.ns.Packet.receive(Packet.java:350)
at oracle.net.ns.NSProtocolStream.negotiateConnection(NSProtocolStream.java:153)
at oracle.net.ns.NSProtocol.connect(NSProtocol.java:263)
at oracle.jdbc.driver.T4CConnection.connect(T4CConnection.java:1360)
at oracle.jdbc.driver.T4CConnection.logon(T4CConnection.java:486)
... 14 more
Unfortunately, being new to Java and Eclipse and Oracle DB, I'm not quite sure what to do with this, and I have been poking around for several hours trying to determine what could be wrong. I'm hoping someone with some experience on this can point me in the right direction.
(Oh, and I'm not an inexperienced developer--just new to these tools.)
Thanks!
I solved my issue, after roughly 6 or 7 hours wasted.
Thanks to this post:
Virtualbox "port forward" from Guest to Host
And specifically to the comment from #Nicholas which made me realize that I had deactivated my Mac's firewall, but not the firewall in the guest OS. Turning that off made everything work suddenly.
I suppose that the default configuration of the guest OS's firewall did allow for SSH on port 2222, as that worked fine even with the firewall in place, which served to mislead me into thinking that there was something wrong with my database driver or connection.
Hopefully this will benefit posterity.
EDIT:
As #HarpreetDawar mentions, the correct connection string to access the database is:
jdbc:oracle:thin:#localhost:1521/PDB1
The one that I was using, ending in :orcl instead of /PDB1, connects to the "container database". I don't fully understand Oracle 12c and the "pluggable database" implementation, but the rough idea is that you can have multiple databases within a single one, and you can turn them on and off by plugging/unplugging them. Hence, "PDB1", Pluggable Database 1.
If you connect to the Container, you will find that you are unable to create a new User/Schema without prefixing it with "C##", which is a tad awkward. That's because the Container is not meant to be used as a normal DB. You connect to the Container to plug/unplug the pluggable dbs (and other things, no doubt).
So if you want to connect to the Container, use a colon and the "SID" (orcl in the VM) in the connection string, and if you want to connect to a Pluggable, use a forward slash and the "Service Name" (PDB1 in the VM) in the connection string.
Anyway, this is additional data that I learned after solving my original problem.
One more thing! A note on port forwarding.
Let's say you now have your VM up and running, and you can connect to your Oracle DB properly, etc. But you have a friend who wants to use the DB with you? Well, that's easy. He should just use the same connection string, with your IP address instead of localhost, and the port forwarding that you set up in VirtualBox should send his connection (using port 1521) straight into your VM. Right?
Well, if you set up your Port Forwarding as From: 127.0.0.1, it won't work, because your buddy's connection is going to your external IP address. So add an additional port forwarding setting, from your external IP address to your VM. Then it will work great!
-Matt
I am the author of the first guide Matt Mc is quoting and taking the liberty to post my comment to his answer as a separate answer for visibility purposes.
I've initially written this guide ~ 2 years ago explaining in detail the process to get the Oracle 11gR2 installed on a Mac using VirtualBox.
Yesterday (25 Apr 14), I've upgraded the same guide outlining all the extra steps needed to get Oracle 12cR1 installed on a Mac using VirtualBox.
Use the following url
url = jdbc:oracle:thin:#//127.0.01:1521/PDB1
to make it work.
Now resolved - see end of question.
I am attempting to debug a Java process with IntelliJ Community Edition's debugger. The socket is listening - but when I try to connect the debug process shows the following
'Connecting to the target VM, address: ':8003', transport: 'socket'
It never makes the connection to the VM and I cannot debug.
I have moved to a Windows 7 64 bit PC - on my old XP machine and could connect and debug this Java process (it's an app I build and maintain).
It does not fail with the standard "Connection refused: Connect" error that you would get if no process was there to connect to. Netstat also shows the port is listening when the app is running.
TCP 0.0.0.0:8003 :0 LISTENING
Debug args for the app
-Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=8003
-Xdebug
If I attempt to run the debug session from IntelliJ on a remote machine, I can connect to the process running on my local machine, and debug.
If I run the Java app on a remote machine, and use IntelliJ on my local machine, I can debug.
It is only if I run and debug on the same machine that it fails - unfortunately this is what I need to do almost all the time.
The only similar issues I have found are from 2004, to do with file paths with spaces, and were NetBeans, not IntelliJ. I have rebuilt and rerun my app ensuring no spaces or underscores in the path, no joy.
My intelliJ debug settings are to debug my local machine on socket, attach mode port 8003 - sorry as a new user I can't attach an image.
Other things I have attempted:
Changing JRE versions
Debugging using shared memory rather than socket transport
I have not re-installed IntelliJ - I am using the same build as my fellow devs (10.5 IC 107-105) who don't have this problem.
Changing the port the debugging process listens on (from 8003 to various other, unused according to netstat)
I have tried using PC name, IP Address and 'localhost' to refer to the PC in the debug settings.
Stuck. Any help much appreciated.
Thanks
Steve
Resolved
Well, a day of failing to solve then I find the answer 20 mins after posting. An invalid JNI signature character, only picked up when debugging. Solved by adding this arg when debugging.
-Dcom.sun.xml.bind.v2.bytecode.ClassTailor.noOptimize=true
http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6547438
Thanks for the assistance. Still don't know why it would work when debugging remotely but not locally before.
It sounds like a strange firewall issue.
It appears that you should be able to try telnet localhost 8003 and it should fail. This means nothing can connect to your app on that port.
EDIT: If shared memory does work either and you cannot connecft it via telnet, there is a problem with the way you are running the app.
You will get this type of error if the application is not running.
Can you try debugging a simple program you lauch from IntelliJ?
I'll like to combine both my initial problem which leads me to this one and this one.
my first problem was to be able to connect jaspersoft ireport 3.7.0 to MSSQL2005.I downloaded the jar from microsoft downloads and added the `jdbc4.jar` from the `irepot>tool>classpath>add jar`.
It went fine but i needed the port number other than 1433 since i'm using a named instance.so my first question is on which port to connect to a MSSQL2005 named instance?
During my search on google i found lot's of article like [this one][1] and [link text][2].i first did: `start>Microsoft SQL Server 2005>configuration tools>Sql Server Surface Area Configuration>Surface Area Configuration for service and connections` and allow remote connection.
I located listenALL at `Microsoft SQL Server 2005>configuration tools>Sql Server Surface Area Configuration>Sql Server configuration manager>protocol for instancename>TCPIP>protocol` which was yes
I Located IPALL at `Microsoft SQL Server 2005>configuration tools>Sql Server Surface Area Configuration>Sql Server configuration manager>protocol for instancename>TCPIP>IP addresses` and as in the second link i posted ,i removed `0` from TCP Dynamic Ports and assigne `90000` to TCP Port
I try to restart the database engine it keeps on saying: `the request failed or the service did not respond in a timely fashion. even though i undo every thing but still.Doesn't start from service manager.And it affected the SQLEXPress that got installed after i installed Visual Studio
i uninstalled the named instance but the SQLExpress is having the same behavior
Anyone to help me?this is critical thanks for reading this
Try to find free port with help of TCPview and then assign your DB Server to it.