Java Application - Upload usage statistics to website?
-
I'm developing quite a popular java application (well, plugin, but for all intents and purposes it runs like an application) and am receiving a large number of users complaining about errors and the line which happen. Naturally, they don't know what a stack trace is or anything like that, so i've come across the idea of having a web interface where I can view each application instances running state and any errors encountered, and its worked will. I've been using FTP where the application uploads a .txt file with the basic stats every time it starts, along with any errors. HERE IS THE PROBLEM: Its gotten so popular that the FTP server has started getting over capacity (and crashing) meaning nothing gets uploaded to the error site any more, and the start up of the application is slowed by 10 seconds while the application waits for a response from a server which is never going to until it times out. HERE IS WHAT I WANT: A solution (i.e. some code and ideas) on how I can get my application to upload usage statistics to a remote server that I can view. Java doesn't want to work with SQL databases and FTP is out of reach. SQL constantly gives me issues when I try to edit it in java - from random disconnecting, to unfathomable data types to web hosts allowing no external access. I have had the idea to make a page which the application can make a POST to, which then updates the SQL database, but that (if possible) requires knowledge of PHP which I do not have. IN SHORT: If anyone knows how I can make a webpage update a SQL database when its given a POST, and read the database when its given a GET, I would be very very pleased. Thanks!
-
Answer:
If you store a POST in a variable, you can run an update query with the value of the POST variable e.g. <?php $stats=$_POST['stats']; //Connect to MySQL mysql_connect("your.hostaddress.com", "username", "password") or die(mysql_error()); //Select a database to use mysql_select_db("Database_Name") or die(mysql_error()); //Run a query with the value of $stats mysql_query("INSERT INTO `statistics` VALUES ('$stats')"); ?> To get the rows in your statistics table, it would probably be better just to run a query and display the contents in an html table instead of writing to a txt file. It takes minimal bandwidth and you won't have to worry about downloading via FTP. e.g. <?php //Note you have to connect to your database first //Get data from statistics table $result = mysql_query("SELECT * FROM statistics") or die(mysql_error()); //Print contents of rows in an html table on screen echo "<table border='1'>"; echo "<tr> <th>Statistics</th> </tr>"; while($row = mysql_fetch_array( $result )) { echo "<tr><td>"; echo $row['stats']; echo "</td></tr>"; } echo "</table>"; ?> PHP has full OOP support so to save yourself the headache, you may want to consider developing your app with PHP. Hope this helps
RjSowden at Yahoo! Answers Visit the source
Related Q & A:
- Which should be used after messing up clustered index? Update statistics, Reindex or Reorganize?Best solution by Database Administrators
- How to upload file to google cloud storage using Java?Best solution by Stack Overflow
- How will the search rank get impacted if i move my mobile website to a single page application?Best solution by Webmasters
- Is it possible to send message to Chrome Extension from Java Desktop Application?Best solution by Stack Overflow
- How to upload videos to YouTube from my website?Best solution by Stack Overflow
Just Added Q & A:
- How many active mobile subscribers are there in China?Best solution by Quora
- How to find the right vacation?Best solution by bookit.com
- How To Make Your Own Primer?Best solution by thekrazycouponlady.com
- How do you get the domain & range?Best solution by ChaCha
- How do you open pop up blockers?Best solution by Yahoo! Answers
For every problem there is a solution! Proved by Solucija.
-
Got an issue and looking for advice?
-
Ask Solucija to search every corner of the Web for help.
-
Get workable solutions and helpful tips in a moment.
Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.