Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 6 years ago.
Improve this question
Ok, so I am a little bit stuck with this problem and could really use some guidance...I have a java application that I have written in Java on eclipse and I also have a database created in mySQL on the same computer, now say I want to copy my java application to another computer on a different network but connect to that same database on my original computer on mySQL, what modifications do I have to make so I can connect to my database on different networks and areas? any guidance or help would be greatly appreciated. Beginner in Java and Databases so please try to explain thoroughly.
Since you use a pure JDBC application you simply need to set the JDBC URL to match with your requirements knowing that the format is something like:
jdbc:mysql://[host1][:port1][,[host2][:port2]]...[/[database]][?propertyName1=propertyValue1[&propertyName2=propertyValue2]...]
So assuming that your hostname is foo and the port is 3306, the first thing that you will have to do is to change the current JDBC URL of your application for something like jdbc:mysql://foo:3306 (assuming that your host is accessible from the other computer and you configured your firewall to accept connections on the port of your database).
More info here
For the second part of the job to do (assuming that you have a static IP address), you will need to configure a port forwarding rule at your internet modem level such that any access to your public IP on a given port will be directly routed to the local IP address of your machine on the mysql port. Check the documentation of your modem to know how to do such thing. Here is more info about port forwarding
Related
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 6 years ago.
Improve this question
I am developing an app where I should be able to remotely access laptop camera's using my app. But how do I write a socket programming as I am new to android, I don't know if by just using Java socket programming is it possible to access laptop cameras
There is a Socket class and a ServerSocket class in Java. You give both of the clients sockets and have them connect to the ServerSocket. If you're remotely connecting to the laptop from your Android device from a different network, then you may need to set up a server to host the ServerSocket part on. Google App Engine can help with that. It also lets you deploy your Java app directly to the app engine via a plugin in Eclipse.
You need to write a simple tcp server-client application, as soon as both devices are on the same network is going to work like charm...
on the Android:
The client which must search and find the server (in this case the pc)
on the PC:
a server client waiting for the android (actually waiting for a tcp client)
As soon as both connect, send some formatted string that will be predefined by you and interpreted by the server as Commands...
with those commands try to turn-off/on the camera, disconnect the app, take a picture etc etc
if you look properly you will find 10000 of examples of java tcp server clients...
good luck!
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
I am working on Lan Messenger, how can I check if somebody else's system has LAN plugged in?
Means, is that person Online?
Also, our hostel has LAN, and I've tried running the client server program a lot many times, but it runs fine on my system (2 clients on the same machine as server) but it doesn't run when server and client are on different machines.
The code is perfectly fine.
What could be the reason? Any special Firewall settings to be changed for allowing packets?
I'm creating a chat server using sockets right now and the way I'm doing it is I have every user query the server about every 20-30 seconds. The server keeps track of the last time a user "refreshed" itself. If a user's gone a certain time period or more without doing so, then the server tells anyone trying to contact this user that they are offline.
Here is a VERY good reference to work off of. Take a look at the Server folder for the server-side and the src folder for the client-side:
https://code.google.com/p/simple-android-instant-messaging-application/source/browse/trunk/#trunk%2FServer%253Fstate%253Dclosed
If you only want to communicate within a LAN, then the socket implementatation in that link is defininitely what you want. If you want to communicate globally( a user in 1 LAN to a user in some other LAN ) then you'll want to redesign it a little so that your server socket is actually on some server accepting client connections. The current implementation creates a server socket within each client and accepts connections from other clients trying to communicate with it. This design breaks due to NAT routers (for reasons I'd rather not explain unless you really want to know).
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 9 years ago.
Improve this question
I am getting this error when i try to make script in bash which copy OAF personalization from one serwer to another. Here is my code:
java oracle.jrad.tools.xml.importer.XMLImporter /ORACLE/apps/apps_st/comn/html_personal/oracle/apps/eng/changemgmt/webui/customizations/site/0/UserAttributesPG.xml
-username apps
-password apps
-dbconnection "(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST= 172.30.32.222)(PORT=22))(CONNECT_DATA=(SID=SRV)))"
-rootdir ORACLE/apps/apps_st/comn/html_personal/oracle/apps/eng/changemgmt/webui/customizations/site/0/
Any ideas?
You are connecting to port 22, which is traditionally reserved for ssh. If I connect to that port with a JDBC connection I get the same error stack you showed in your previous question:
Exception in thread "main" java.lang.StringIndexOutOfBoundsException: String index out of range: 25978
at java.lang.String.checkBounds(String.java:401)
at java.lang.String.<init>(String.java:338)
at oracle.net.ns.Packet.extractData(Packet.java:429)
at oracle.net.ns.RefusePacket.<init>(RefusePacket.java:72)
at oracle.net.ns.NSProtocol.connect(NSProtocol.java:356)
at oracle.jdbc.driver.T4CConnection.connect(T4CConnection.java:1102)
at oracle.jdbc.driver.T4CConnection.logon(T4CConnection.java:320)
at oracle.jdbc.driver.PhysicalConnection.<init>(PhysicalConnection.java:546)
at oracle.jdbc.driver.T4CConnection.<init>(T4CConnection.java:236)
at oracle.jdbc.driver.T4CDriverExtension.getConnection(T4CDriverExtension.java:32)
at oracle.jdbc.driver.OracleDriver.connect(OracleDriver.java:521)
at oracle.jdbc.pool.OracleDataSource.getPhysicalConnection(OracleDataSource.java:280)
at oracle.jdbc.pool.OracleDataSource.getConnection(OracleDataSource.java:207)
at oracle.jdbc.pool.OracleDataSource.getConnection(OracleDataSource.java:157)
Well, slightly different stack because of how I'm connecting and the version I'm using, but the String index is identical. Looks like ssh is responding to the connection with more data that the JDBC driver ever expects to see back from a listener.
Changing just the port number to a valid SQL*Net listener port removes this error and the connection succeeds.
So, change to use your listener's actual port number; 1521 by default but you might have something custom. lsnrctl status will tell you what it is. It's unlikely to be 22 even if it is customised since that is in the privileged range and the listener would need to be running as root to bind to it.
The only reason I can think you might have tried this is because you're tunnelling your SQL*Net connection over ssh, to a remote server. If that is the case then you need to use the local port (from a -L flag) that maps to the actual listener port on the remote server. So if you had, say, ssh -L 1234:127.0.0.1:1521 -l user 172.30.32.222, your dbconnection would point to localhost and port 1234. I'm speculating as to why you'd have used 22 though, clearly.
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 9 years ago.
Improve this question
I am running Linux Fedora 18 and all I want is my java code to print hello linux in a web browser I type in http:// myhostname. I have use my code in windows and it work find. However in Linux I use port 80 got a permission denied. So I then I use port 8080 no permission denied but it didn't work. Using port 80 the client dose accept and I can send and receive information only on machine the seversocket not on a different even if it is connect ton the network.Last thing I have made policy file to allow port 80 to work but it was useless and I still not sure I to set a policy file in my code. Sorry if this long question but I have been researching this issue for a month not so please don't tell me to google it. So I guess my main question why can't the serverSocket broadcast anything out of the linux machine and how to fix it?
Thank you
On Linux, you need to be root to use system ports from 0 to 1023. Tomcat has ways of opening port 80 without leaving the process running as root, but they are a bit complicated to discuss here. Linux provides ways to give permissions to access these port, but usually I just use port 8080.
If you use port 8080, you need to redirect this using your router to port 80, or you will have to specify that you want to connect to port 8080. Your browser only assumes port 80. e.g. http://yourhost:8080/
To connect to this server from another machine, your firewalls have to be setup so you connect to it all. A firewall is designed to stop traffic you haven't explicitly allowed. This means you may need to open your firewall on your server, and you network router and put the your public IP address (not your internal one) in the hosts file of your client.
I did a yum update and the code work just fine now.
Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 9 years ago.
Improve this question
I have a server written in Java which basically awaits requests from different clients and serves their requests. I am running this server from Eclipse. This server is accessible on the local network but I want to be able to access this service from outside the local network. Is there any way to do this please?
P.S. I am a real beginner in these things
you can open a port in the router that leads to the one that the server is listening on. You then connect to your public IP. This ip can be found on
As #Java Player said, the problem is that your router(Nat) denied any incoming packet to your local network...briefly, there is many solutions for this:
Third party server: you must have a dedicated server that plays the role of intermediary, between your client/server programs.
Pros:
Solve completely the problem related to the Nat.
Cons:
In addition of your client, you must code another third party that forward packet to the desired destination.
BTW it gets a little heavy(waste of bandwidth).
Reversed connexion: the server and the client program are reversed, that's mean the client become a server and the server become a client, 'used by most of trojan...
Pros:
Very easy to implement this approach.
cons:
You must at least has an opened port.
Udp hole punching: this approach is used by perhaps all peer2peer solutions(eg: skype, utorrent...).
Pros:
You don't need to any router configuration.
Direct connection between peers.
Cons:
You need also a third party server called STUN server to get informations about your router.
Not all router that works with udp hole punching, you must consider also the first solution.
Writing a hole punching solution is not easy task.
You could also download something like Hamachi and then download Hamachi and sign into your network on the other PCs and Macs (and Linux...which is currently in beta). Then you'll want to be able to access your server on.
Main Hamachi product page
Linux Beta