How to log data of a Java(FX) application? - java

What is the best way to log data of a Java (also using JavaFX) application for later reviewing? A few other people and I are working on a project, with a client/server model, and we want to log all data in the server for reviewing it later and possibly use it for calculations (later).
So a simple text file won't do, because the data needs to be reviewed in a clear way and can be used for later calculations. You can say that we want a small database that integrates well with Java, but using one like MySQL will require all the server setup and it seems to cumbersome in this situation.
Does anyone have any suggestions?

Probably the best option right now is to use slf4j as the API, and logback as the implementation.
That'll allow you to change the physical repository of your log data, without changing your code.
I also suggest you to read this article:
http://glauche.de/2009/09/09/java-util-logging-vs-slf4j/

The JDK commes with the java.util.logging package. This gives you all you need for logging.

Related

Creating java applet or windows application that has internal database

I want to make a form or applet that will serve as GUI to a "database". The basic outline of it will be just a menu where people can put in a date and then all of the items related to that date will show up. I also want to have an insert option where people can add information for a date.
However, I was thinking if this could be possible with creating a database. I want to have this be pretty portable and give it to anyone so don't want to have to deal with connecting to database and installing DB server and all that.
Is it possible to keep all the data within the program and the filesize of the program just grows dynamically as more information is put in?
There are several "stand alone" or "single user" database engines around.
H2
HSQLDB
As I understand it, Apache Derby and even Java DB can be configured for "single user" operation, but you would need to verify this.
If you don't care about having a Java based database, you could also look at SQLLite
Applets have very restrictive security constraints, generally meaning that they can't read or write files to a local disk. You can run a in memory database, but once the applet/database is closed, the data is lost
There is a very lightweight file DBMS called Derby, created by Apache. Take a look at it here: http://db.apache.org/derby/
It's free and simple to use. It is not a very powerful solution, but it does sound like something you need.

Java Messenger : save message archives on the computer

I am doing a Java Messenger for people to chat and I an looking for a way to record the message archives on the user's computer.
I have 2 possibilities in my mind :
To Save the conversations in XML files that I store in my documents folder.
To use SQlite, but the problem is that I don't know how it is possible to integrate it to my setup package and I don't know if it is very useful.
What would be the best solution for you ?
Thank you
Another option is using JavaDb, which comes for free with Java 6 (and later versions)
Before you make a choice, you should think about questions such as:
presumably you want this transparent to the user (i.e. no admin involved)
is performance an issue ?
what happens if the storage schema needs migration
do you need transactionality (unlikely, I suspect)
etc. It's quite possible that even a simple text file would suffice. Perhaps your best bet is to choose a simple solution (e.g. a text file) and implement that, and see how far it takes you. However, provide a suitable persistence level abstraction such that you can slot in a different solution in the future with minimal disruption.
I would go for the XML files as they are more generic and could be opened outside your messenger with more or less human readable format. I use Pidgin for instant messaging and it saves chat history in XML. Also to read the history from your application you can transform then easily in HTML to display it nicely.
If you use JAXB, converting Java objects to/from XML is very easy. You just put a few annotations on your classes, and run them through a JAXB marshaller/unmarshaller. See http://docs.oracle.com/javaee/5/tutorial/doc/bnbay.html
Use google's protocolbuffer or 10gen's bson. they are much smaller and faster.
http://code.google.com/apis/protocolbuffers/docs/javatutorial.html
http://bsonspec.org/
One issue is these are in the binary presentation and you might want to make the archive transparent/readable to users

Desktop DB Application with Java

First of all, I'm sorry for a long explanation.
I need to develop a desktop app that will enable users to enter patients lab results for tracking diabetes treatment.
I usually code in php/mysql, but I'm not allowed to use it (my first choice was to use LAMP / XAMPP, but was told not to do so). I was told to use MS Access, as the easiest tool, but since I've never used it before, it gave me a lot of headache. Its wizards are great, but I needed to use data from several tables in my forms, and was simply unable to efficiently do so.
So, here is my question: What sort of db can I use with Java to create such an Application? As I said, I'm most comfortable with PHP/MYSQL combination, but during my studies I also used Java quite a lot. If I could find some sort of 'template' for such an application, I could probably create this easily.
I found this http://netbeans.org/kb/docs/java/gui-db.html using google. How complicated is this?
I need to create this ASAP, since I need to get this App to a team of medical staff, since I need this data to use as datasets for my MSc thesis (related to case based reasoning). I'm really behind schedule here :). And someone will probably break my neck if I don't develop it in a few days and start working on a theoretical part of my thesis.
Thank you in advance.
Okay, this one is near and dear having just been diagnosed as pre-diabetic.
What's not completely clear from your description is if you are keeping a separate database for each instance of the app, or are you sharing the data in one big remote database?
And how much data are you expecting?
If it's just for each instance, then any old database will work; the lightest weight one is actually probably sqlite3, but since you're in a hurry and used to LAMP, mysql will certainly work.
For remote data, go with mysql.
Either way around, there are plenty of ways to connect to the database, most all of them based on JDBC. It seems like you basiucally need two tables: patient, and labs. Patient will be something like <name,dob,ssan,address>, and labs something like <ssan, labtype, value, units>. SSAN would be the key and a record would be something like
123-45-6789|A1C| 6.0|pct glucolated
In that case, I'd just make the tables, have two forms with the data, and don't try for anything too fancy.
Update
Okay, from your comments, yes, either use Derby or just use text files. Do you need any particularly complicated queries? In the Old Days we would just have made something like a CSV file and read it into memory.
Oh, and look into Java Web Start for distributing the app.
You can use Java to connect to a database via JDBC. Check out this tutorial. http://download.oracle.com/javase/tutorial/jdbc/index.html. You can use mySQL as your database. You can also use embedded databases such as derby which don't require an external database application.
Here are 2 tutoriala how to build CRUD application on top of the NetBeans Platform (a Swing-based RCP):
http://platform.netbeans.org/tutorials/nbm-maven-crud.html
http://platform.netbeans.org/tutorials/nbm-crud.html

Is it possible to use multiple programming languages on one website

Suppose i have one website with simple pages in php like
page1.php
page2.php
Now there is one page where i want some detailed functioning and i want to use python for that and it will look like
page3.py
and in other page i want to use java like
page4.jsp
Provided i have installed python , java on webserver.
Is it possible?
Yes. It's possible. Where you will find yourself in trouble is when you want to share server-side information among them (I.E. sessions).
Other than that, you can use (but I would advise against it) all languages you want on a website.
Yes, it is possible, but you definitely should NOT do it.
Communication between pages running different technologies will not be elegant, if for no other reason than the fact that you won't get a shared session pool. Session bridges are possible, but they are a pain to do.
I would say you are making a mistake if you can't just pick a single language for your core web layer.
Yes it is very possible, as long as the server can serve the files you want to use. If it doesn't have python, you can't use python.
It depends on the web server. Apache can do it. Just make sure you have the appropriate handler modules for each file type, and use the AddHandler configuration directive to map each type to the appropriate handler.
Also, to be pedantic, you can not only use all three of those, but you can actually integrate them at the session level, since all of those languages are available on the JVM. So, in one container you can run all of the PHP, Python, and Java code. You can share session state, reuse connections to the database (via server wide connection pools), leverage Java libs in your PHP and/or Python code, etc.
I'm not saying this will be "drag and drop" easy, but it is possible, and even practical if you need that kind of close integration (vs integration via a database or filesystem). There will likely be nuances in ensuring that the Python and PHP code runs properly on the Java implementations as well.
Short answer: Yes, many web servers can handle generating pages from multiple languages.
People are talking about session...
Almost all server side technologies today support custom session providers, where you can hook up some code to share you session between different HTTP modules and binders.
If you are starting to write a web site from scratch, and you need to write all of your code for yourself, than probably you will choose to do it in one programming language (only for your comfort of coding).
But... where it's all starting to change? When you want to mash-up some open source and community source code to make a web site. Let's say a store & community with ASP.NET to mix up with CRM like Sugar CRM (which is in PHP).
In that case you don't need any session sharing, just users sync procedure in the DB.
Also, if you choose IIS 7 (Windows Server) or Apache (using Mono project you can run ASP.NET on LAMP), you could run them both on the same machine.
And remember, the most important thing is TIME TO MARKET! So saving code time can be crucial for you success.
ENJOY!
I work for a PHP development company and all the time these ASP.Net companies come to US for whatever reason I've never understood. We build them forms in PHP usually dynamically pulling in the layout - sometimes hosted on a subdomain, sometimes hosted directly in IIS with the PHP module. Its very messy and bad, it can be done but I'd say avoid it.
You can use Apache Reverse Proxy to do it and session must be readable between programming languages. I use Go, NodeJS and PHP in one website. Session is saved in Postgresql. The hardest part is all programming that is used in your website can read session with same format and saved in same place. I have used github.com/yvasiyarov/php_session_decoder to read and save session with Go and save it in Postgresql so PHP can process that session

Where can I find an AS400 to Java interface?

Does anyone have links and resources to connect to an AS400 from Java?
I remember years ago, somebody told me about a connector that simulates KeyStrokes from the keyboard and other "purest" approach that connected directly.
On the web I have found a lot of links, but I cannot find a complete product to do this (I am probably not using the right keywords).
EDIT
Thanks for the answers:
What we are looking for is a way to access the data inside the AS400 and/or the screens it uses and expose them for other new applications re-use. Either as a webservice of some sort, or directly through Java ( and java will expose the operations using webservices )
Thanks in advance.
EDIT
As per MicSim post, I've also found this link:
http://www.ibm.com/developerworks/library/ws-as400/index.html
What you are looking for is probably the Toolbox for Java™ & JTOpen from IBM. There is also an AS400 class in the toolbox for performing specific AS400 tasks. You can look here and here for more details. Just googled it and hope it's helpful.
IBM's 5250 screen-scraping technology was "WebFacing" - I would post a link but you're probably better off Googling it, since IBM's documentation is so scattered. There are other technologies available too but: Screen-scraping was never anyone's favourite since typically you end up with something which, although it looks more up-to-date, actually is harder to use than a green screen and no more functional. The 5250 is probably the single best data entry platform I've ever used - web forms in a browser are one of the worst.
As mentioned, jt400 is the way to go for most other things. In particular:
JDBC - for all things SQL. If you do it right and address your files as though they really are tables, it's a way to get away from the 400 entirely.
Record-level access - write Java programs using a similar database API to RPGLE (all those chains, setlls that 400 programmers love)
Call programs, system commands, manage resources (data queues, data areas, prints / spools, jobs etc etc)
Good luck
If you just want to run Java on the AS/400 (or iSeries, or System i, or whatever IBM's marketing department has decided to call it this month), that's a supported language. You can access the pseudo-DB2 database directly. Or are you after some other form of integration?
This obviously depends on what you want to do, however if you want to simulate keystrokes across a network connection to an AS400 process then Expect4j may be the library you are looking for.
This is generally a really nasty hack though and there are frequently better ways to achieve your goals. What are you trying to do?
The expect4J library can be found here. Expect was originally a unix command that allowed you to specify a string that you are expecting to see and then a string of characters to return. It was frequently used for automating logins etc and for screen-scraping applications.
Even better is the TN5250j Console, which can be used to extract data from the AS/400.
jacada makes tools to do what your looking for
http://www.jacada.com/

Categories

Resources