Android + SQL Server + jTDS - java

I'm trying to build an android app with connection to our SQL Server. I have downloaded the jTDS JDBC Driver. I have an jar file and have to copy it to my application's classpath. But where is that? I have copied to my workspace in the project directory where the file ".classpath" is. But it seems not to work.... everytime if I'm at the code where I load the class with
Class.forName("net.sourceforge.jtds.jdbc.Driver");
it says:
The source attachment does not contain the source for the file ClassLoader.class. You can change the source attachment by clicking Change Attachmend Source below"
Any ideas? I'm new to java AND android...

no need of that much of mess.
Simply for Mysql Server Data Access or any live server data access.
Make Use of Web Services
Its like prepare a dynamic page that have all the fetched data result from the server. Your android application need to hit that dyanamic page URL and then simply read the content from the streams and use them in your application.
Genrally large amount of data is expressed in xml format which is then parsed from the application See on google about SAXParser
In short its like a web page that will echo your server data after your app hit the url of that web page to read the data.

Related

update MDB file remotely from other java web server over http

How to update an MDB file from other machines remotely over the HTTP?
I have 2 machines that are connected by the internet, on the first, I have an MDB file and on the other, I have a java web application, I want to send an SQL query from the java web application to update the MDB file on the other machine over the HTTP.
I tried to use FTP, but it is transferring the whole file b
A file such as word, or power-point or Access?
Well, a horse is a horse is a horse.
A file is a file is a file.
You don't connect to a word file to update it. You don't connect to a Excel file, or a power-point file. And you don't connect to a Access file. You OPEN a file, and THEN modify it. You can't open nor modify files over FTP, nor can you modify them over HTTP either. And you can't even do that with a plane jane text file. These are files - you have to open them to modify them. Or pull a whole copy to one side. Update that file, and then send it back.
So, you don't want to confuse the concept of a simple file, or file based system like say a text file, excel file, or Access file. These are NOT servers or say a service that you connect to. You never open a MySQL file - you connect to a server + service via tc/ip (a socket conneciton) and then send commands back and forth. You NEVER open or touch that MySQL data file. The server updates that file - not you, and not your code.
So, Access is not a server based, or socket connection based service. It is a file based system - not un-like a text file. You don't connect to a text file, you HAVE to open that file - modify it and then save it. You can't do that over http. In fact you can't even do that with FTP either. You can pull the whole file, modify and then send it back to where you got that file from.
Now, you could however setup + create some web service calls or entry points on the one site. You could send that web site some commands, and then code behind on that web site can open up that text file, word file, or in this case the Access file and make changes . But once again, just like MYSQL or say the web server? You not opening the remote file direct - are you? You are (and can) thus setup some code or web methods (even REST ones) that accept commands, and those (even sql update commands) could then be run by that remote server/service and thus update the file on that target system. In the case of Access data files?
If you look VERY close, even a ODBC connection string ALWAYS ALWAYS resolves to a valid windows path name (and a full legal qualified windows path name at that).
so, while there is a ODBC driver, the software driver still in fact uses a standard windows OS file open command against that plane jane file sitting in the hard disk. So to update that Access file, you need the driver - since it knows how to open that file, and how to update the delicate data file structures inside. So, even via ODBC? Well, it not a socket connection and you not connecting to a server on the other end - but in fact opening a simple windows file. In fact this means that you not only require DIRECT file rights to that access data file - but you actually need the windows file system!
However, sqLite is the SAME thing. There are thus some jdbc drivers. This JDBC concept is VERY similar to ODBC, but is for web based systems. You install a library on one end (where sqlite resides), and then that web service can take your sql commands (updates or query pulls), and thus the web site code now opens that local file, executes sql against it, or does a query pull , and then returns the results of your query - and the web query calls are done via that web service (rest calls) on that server. So, you can in theory shuffle commands between two web servers - and there are some types of "drivers" such as jDBC standards that in theory do wind up giving you a similar experience to ODBC.

Unable to configure JSON in android studio

I'm working on a project. There is a website coded in asp.net and database is SQL. and there is a mobile app connect to this site.in app it used JSON and no db codes. I added new tables to this site and I want to configure it from android studio. I'm new to JSON so I can't config the database from android studio. And I want to know what is a .ashx file is? I can't add code snips due to privacy policy in company. Thank you very much!
.ashx file details:
A file with the ASHX file extension is an ASP.NET Web Handler file that often holds references to other web pages used in an ASP.NET web server application.
The functions in the ASHX file are written in the C# programming language, and sometimes the references are so short that an ASHX file may end up just being a single line of code.
Most people only encounter ASHX files by accident when they try to download a file from a website, like a PDF file. This is because the ASHX file references the PDF file to send it to the browser for download but doesn't name it correctly, attaching .ASHX at the end instead of .PDF.
source: https://www.lifewire.com/ashx-file-2619693
And as far as I think for accessing JSON in the android studio you can look into volley.
Volley Documentation: https://developer.android.com/training/volley

Retrieving data from web browser's download manager using java

I want to try creating a program that can automate the storing of web address that is available on every downloaded file on a web browser.
My problem is I don't know where to start.
What am I planning to do is just save all the downloaded file's web addresses in a excel file.
Sample image using google chrome
I think Firefox stores the download history in the places.sqlite file in your Profile folder. You would need to open and read that file, but you probably can't while Firefox is open (it has the file open).
http://kb.mozillazine.org/Places.sqlite
From there, you can process the data in your Java app and then write an Excel file, perhaps using Apache POI (the Java API for Microsoft Documents)
https://poi.apache.org/
Where and how, download history is stored varies from browser to browser . In case of Chrome on Mac it is store in the path
~/Library/Application\ Support/Google/Chrome/Default/DownloadMetadata
as SQLite format.
You need to write an application to parse the data and create xls

hosting the database file on any cloud service

I have an android application, which wants the user to login each time he runs the app. So, the login procedure is simple, using the sqlite dabase file i'm using. I've copied the file in assets folder and doing the necessary modifications. But, the database file is of no use unless it is on the server. I don't have any server so i'm thinkin of keeping the database file on dropbox, google drive etc and then read or update that file as per user commands. The question is how to do that? I was searching the web for it, and found that the only way is downloading the db file modifying it and the uploading it back. Can anyone give me an example??
Doing that isn't possible unless you have a server.
Because, if you are using dropbox, first you'll have to make your file public in order to download it (Not recommended at all. Compromises security). Then you can use the url to download the file. But you won't be able to upload it back (Unless you are able to login to dropbox through your Android code).
Instead if you a web server with MySQL n PHP, you can easily send POST requests to your server.

Remote query from Java code

I'm designing an Android app that stores its data in xml files locally; local data are part of all data stored at a server. I need remote file path to download and view locally. user can list remote files in a listView and check files (eg.. books) to download;
What can the structure of the remote repo be? (SQL) How can I make the query and receive result? (JSON) Any way to sync (subtract existing files from remote)?
your question is too generic and wraps a big thing stuff, since you are asking the repository, the query mechanism and the sync between the server and your app.
the most common way to do this is allocating all you data in server database (mysql i.e. or xml files, last is too more complex) query it with a (php, jsp, asp.*) web service and retrieving the web service result (in your android application) using HttpURLConnection, URL classes to connect and read the ws result.
Later, the sync can be on a background thread that continously do the above operation.
maybe you can do it with the DownloadManager service, but i recommend you a little read to the documentation.

Categories