Closing a connection made to Azure file share with Java SDK - java

I am working on developing a file system manager client that connects and do file handling with Azure file share using Java.
By referring Azure docs I could see how a connection is made with the connection string and how the file manipulation is done. But there is no such thing as a connection close step.
I wonder if for Azure, created connections automatically get closed or is the doc missing something? As far as I know, if a connection is made, that needs to be closed after the tasks related with are done.
Help me clarify this.

Considering the SDK is simply a wrapper over HTTP REST API, the moment the operation is complete (i.e. response is received), the connection automatically closes. You don't have to do anything special to close the connection.

Related

How to handle Android to MySQL updates when smartphone is offline

I am currently working on a forum-like Android app which interacts with a MySQL database through JSON and PHP scripts. On certain occasions, the app has to send updates to the database, e.g. when a post to the forum is made or updated.
My question considers the situation that the smartphone is offline, i.e. doesn't have a internet connection thus cannot connect to the server, and tries to post something to the forum. However, due to the offline status, it cannot interact with the database immediately. In this situation we want to handle the messages in such a way that the post is sent to the database on the next instnce when the device connects to the internet.
What exactly has to be done on the app side to achieve that?
I guess the post has to be buffered in some directory locally and the app has to check the internet connection constantly. Does anybody know how to do that? Does JAVA provide certain functions for doing this?
Thanks in advance!

How to use a URI in java

Application use: I am creating a connection between a tablet and a desktop. This tablet will send command to my desktop that my java app will then interpret and do accordingly. One of these features I would like to include is controlling Skype. Such as focusing on it. Switching chats. Initiating call. Sending message. ect. But I can't seem get the URI api to work. (This is the only known api that will allow me to initiate calls and chats, so if you know of any other. Please do tell.)
I am not sure If I am doing it right being that this is my first time using a URI ever. This is what I have using
import java.net.URI
public void uriTest(){
try{
URI uri = URI.create("skype:echo123?call");
}catch(Exception ex){
ex.printStackTrace();
}
}
What am I missing? I know it is probably a lot. Is there some sort of way to implement it. Or when you call .create() does it automatically do it for you?
Any help or clarification will be greatly appreciated.
Your code constucted an URI and now you have one, nothing more, nothing less. An URI is - as the name "Universsal Resource Identifier" says - just an identifier.
What you probably want to do is establish a connection to a location identified by that URI. So you need a special identifier, a so-called "Universal Resource Locator" or URL:
URL url = new URL("skype:echo123?call");
Still nothing happening since we only defined a location. Next you have to connect to it:
URLConnection conn = url.openConnection();
Now you got an URLConnection-object (in this case a HttpURLConnection) and you can operate with it: post data, read responses etc. Read up on the API of java.net.HttpURLConnection to learn more.
You should write a web application, and deploy it on a web server program such as Tomcat, on your desktop machine. You can then write an app on your tablet which would connect to the server and send commands to the server.
The web application could parse the commands and do something with Skype application running on the desktop.
You would probably write a JSON api and deploy it on the Tomcat server, and then invoke the JSON api from the tablet app.

Bluecove Close connection issue

I use Bluecove 2.1.1 and trying to restart bluetooth service, but after closing connection and reopening I can't connect to service, I got "Connection refused" exception. I found this issue on Bluecove site? I also try to change service name(also UUID) after closing connection, but it's not help. Does anyone know workaround for it? I'm simply need to restart bluetooth service.
I am not sure if I understood your question in the way it meant to be.
I assume that you are opening a Connector and let a SessionNotifier handle OBEX connections with accecptAndOpen(ServerRequestHandler).
When a clients connects to your bluetooth service the specific methods in your ServerRequestHandler are called (onGet, onPut, ..). When the client disconnects onDisconnect is triggered. Now you need to acceptAndOpen your service again to handle future connections.

Java Servlet: Retrieve data from remote devices and "push" data to client side by using FTP connection

I believe build a small home-made program to make ourselves more comfortable is quite common nowadays. Just few days before, I really tired to get the same named log files from different remote devices through FTP connection again and again so that I started to build one Java web application.
The purpose of the Java web application is simple as once the user filled in the absolute path of source file in remote device and selected corresponding remote devices he or she want to connect to, the web application will finally store those same named log files in user's local computer with well organized folder structure. You can simply understand that this Java servlet is a proxy sits between client and remote devices.
Currently, I have already done and tested the downloading function from remote devices to the server in Java servlet by using Apache common net FTPClient library. It worked fine and provided me the copies of same named log files in a well organized folder structure.
However, when I moved on, I realized that the "pushing" function maybe the killer. Following are few queries I want to discuss with you all:
Even I could get IP address or host name from client's requests, is it possible or suitable for me to auto establish a FTP connection from servlet to client?
If an auto FTP connection is achievable, what are the security concerns I should pay attention?
If an auto FTP connection is not achievable, is it possible or suitable for me to return those files in the response to the client?
I appreciate your comments or suggestions. Hope you all also enjoy the open discussion here.

how to share a database to different pc's for a java desktop application?

I am making an application which have to be used in different pc's, and it has to share the same database. I have no idea how to do it. I am using the java as programming language and mysql as database. Please help me to do this task...
Use JDBC and connect all your app to one MySql DB Server
The way to talk to a database in Java is JDBC.
See http://download.oracle.com/javase/tutorial/jdbc/index.html for a good tutorial on how to use it.
On server-side you should create user which will be granted privileges to access your database from different foreign hosts:
GRANT ALL ON *.* TO 'someuser'#'somehost';
Read more here: http://dev.mysql.com/doc/refman/4.1/en/grant.html
On client-side you should configure database connection to use host where your database is installed. Read JDBC API reference for details.
Does a client-server model not work for you? If you have somewhere to host a server the normal method accomplishing something like this is to encapsulate your database behind the server and all clients connect to your server to exchange information.
You have a variety of options for communicating between the clients and the server:
Your server could be a simple web app where your clients all make URL calls to the server to accomplish various tasks. Implementing REST or SOAP would make the calls even easier if you're doing anything non-trivial.
RMI if your not going over the internet makes things really easy (you can get the basics of RMI in a few hours of reading).
Assuming you have the network connectivity, you can also just have each client make their own connection directly to the database. But only do this if you are on a safe intranet only.

Categories

Resources