Passing java query result to fields / UCanAccess Compatibility - java

I have really low knowledge on Java and JasperReports, barely used those to play around, nothing too serious. A friend of mine has been trying to get someone to develop him an application that will generate PDFs with information from an access database for each of his clients, however, after 6 months and 7 developers who ditched him, he has found none, so he asked me if I could help him to which I said I'd give it a try.
What I have been able to do so far:
So far I've managed to successfully (Everything has been done separately, I have like 8 projects in total so far):
Use Jaspersoft Studio/iReport to create a single PDF with the required client information on each sheet.
Create a separate JasperReports project with a input field to get a pdf with a single client information.
Create a Java App with a JFrame to launch the report generation.
Create a Java App to connect to the access database through ucanaccess and validate the search criteria
Questions:
Now, after a few days on Google up and down I havnt managed to successfully achieve everything that I'd like to achieve, and I'd love if someone could either point me into good noob-proof guides or (if willing) provide a noob-proof answer so I can continue to move on.
Create a Java App where you can choose to generate all client's report or a single report for a specified client (I am assuming this isn't too complicated since it'd just be a matter to embed both Jasper reports into the java app), however I'd need to pass the input value into jasper report field to generate a single report (Not sure if this one was clear enough), and run the query for the data-set based on that field's value.
Ideally though not highly needed, pass yet another variable as a field to set a date range.
Since this is being done on a MS Access Database -*.accdb- (Don't blame me, I've been telling him to move to MySQL/SQL for quite a while now), I'd love to know if its possible to make JasperReports do a query based on a UCanAccess JDBC connection (Tried a few options, none worked).
Finally, I need to generate in the report a date range (Something like: "Between 1/Jan/2014 and 1/Feb/2014")
I feel like I've made a decent amount of progress so far, but since I am no pro on either JasperReports nor Java, I am getting stuck in a point where more knowledge is required to create a more decent and practical piece of software and I'd love if someone could point me into a better direction (Either if something is impossible or just a few links to help me get thru)

-Remeber to add ucanaccess jar and all dependencies jars in the Driver Classpath, while creating the Data Adapter
-You have to set Showschema=true:
e.g.
jdbc:ucanaccess://c:/db/database.accdb;Showschema=true
In this way Jasper Studio will be able to navigate the metadata of your database, and you'll find your tables under the PUBLIC schema.
Then you'll be able to create your reports as usual.

Related

Liferay 6.0 get WebForm-portlet data from db with java controller

I have some webform portlet used, for example to ask users if the experience in the website was good.
Now I need to get the web form values and create a table to show them. I know that data are stored in liferay's DB in the Exapando (tables, ros, column, values). The problem is that i can't find web form name. In Expandotable it is stored like 1_WAR_webformportlet_INSTANCE_... but I want the name that appear in browser ("MY FORM" for example).
Hope that someone can help me...
PS: I'm Using ExpandoTableLocalServiceUtil in JAVA.
The Expando API mimics tables and you can find various other Expando* API classes that you will need in order to extract the right data. It's not the most intuitive way to run reports on the data, as it's largely built to store extra values for existing entities.
That being said, once you have a proper id from the ExpandoTable of your choice, you can query the ExpandoColumn and ExpandoRow APIs, and in turn the ExpandoValue API (add LocalServiceUtil to all) to get the proper values.
Then, of course, you'll need to render these values in your HTML output.
Web Forms can also be exported as CSV, you could use that output, or you can look at that code, as it also reads all of the data for a form.
I can't go without: You mention Liferay 6.0 and tag Liferay 6.2. Both are horribly outdated - please run more current software on a public facing website.

How can I make my java program retrieve data sets online?

Currently I am working on a program that will assist me for making decisions when trying to bet on sports. My goal is for the program is that each day I would like to retrieve things like weather, past games, player/team stats etc. then aggregate it all so that I can see which teams make the most sense to bet on.
I'm not exactly sure if it's even possible to do on IntelliJ, the text editor I'm using, because I do not think its connected to the internet on its own. I think one approach would be to use a separate program (not IntelliJ) to automatically go to each website and copy the appropriate information into an excel document; then I could copy the file into my project each day before I run it. Something like that is what I have in mind, but I would appreciate some help if anyone knows which strategy I could use to move past this obstacle.
I've recently learned how to and created a GUI to navigate my program a little easier than through the console; therefore, my work ethic is not an barrier in this instance. I've taken one programming class in college and would consider myself an apprentice (one step above a novice).
You can use jsoup for scraping data from a website, Then you can use Apache POI to add it to an excel file.
Heres the website https://jsoup.org/
Heres a good tutorial about apache POI https://www.baeldung.com/java-microsoft-excel

Maximiser CRM Data Migration, UnEncoding Email Text from Binary Image Column

Hi Firstly I realise this is not a direct programming question as it is more data related so if it needs to go elsewhere fair enough.
I'm trying to extract Email Message text from a Maximizer CRM system for a Migration.
This information appears to reside in the AMGR_Letter_Tbl, however I’m having a few issue decoding it.
The Column in Maximizer CRM’s documentation at database level is described as a “Binary Image”, this appears accurate and for some entries (Documents) in the table casting via MSSQL obtains a readable response (See the bottom 2 rows in my query results).
However for Email Messages there appears to be at least one extra level of encoding or encryption applied. (See the my UnEncoding attempts below).
I’m hoping some one will either have encountered this issue before, know from experience with Maximizer CRM what’s needed Or will recognise the next step needed from my un-encoding attempts.
If you do know please describe what un-encoding, casting, other procedures and there required order or application.
I will be fitting this into a bigger Talend migration when I know what decoding is needed so any code examples in Talend OS or Java would be appreciated.
Cheers Andy
Just to let you know I solved this issue and the contents of the table are Microsoft OLE encoded OLE File format info
I now have an extraction method that recovers Documents, Emails and Emails attachments stored this way.
The scripts are using a number of system tools and third party Java library's controlled via Talend.
However I can't give too much away as to create these has taken a significant amount of time and effort.
If you want more info please get in contact directly.
Cheers

Do I need a database for my game?

I will develop a game in java which is about chemistry experiments that include quizzes and lessons . I need to store only two things in my game which is
Score of the quiz
the experiments that the user finished in order to put some sign or change color or whatever to indicate that this one you have already finished it in the experiments menu
Do I need a database ? I read about XML and it used to store simple things . But as I far as I know that XML work with web and my game is offline, how am I going to use it in my case ?
Also , someone told that I can use simple text-based format . But how ?
If you're not planning on making the game online, then you don't 'need' to use a database. You can use an XML (which can be used offline as well as online), or you can use SQLite.
On the text based format thing, it might seem easier to use, but it will cause you trouble on the long run. My suggestion would be to go with XML.
You can learn about XML here as well as how to parse them.
XML should work fine and would probably be my approach to this problem. It's not tied specifically to the web. It's an extensible format for data that has many existing libraries in many different languages including java.
You also have other options like CSV files.
You can use a file-based local database like SQLite but it sounds like overkill for what you've described.

Exporting Access Tables Programmatically

alright, after a few hours of searching and reading all over the net, I have broken down and decided to ask for help. I am working to automate many of the more medial and repetitive tasks as work, and stumbled upon AutoIt, I love the tool. anyway, Today's task is the export of a slew of tables and queries from Access 2007 in a few different formats. mostly CSVs some Tab delimited, and a couple of dBase DBFs and DBTs. now none of this is all that difficult and in fact the person who previously held my position created about a hundred Macros in the mdb that export the tables. seems to me that he fell well short of hastening the process as you still have to run each macro. I am looking to create an autoit script that will export the correct tables in the correct format to the correct place with the correct name. doesn't seem like it should be that difficult.
so thus far I have been imagining using ADO to tell Access to export which table in which format and where. but I cannot seem to find the necessary commands needed to do that. I also figured that perhaps, at least with the text based formats (CSV, txt, tab) I could read each record out of a given table or query and then build the text file myself in autoit, not the simplest way of doing it, but it could work. The problem arises when trying to create the dBase file, I haven't a clue where to begin with that.
I am open to using JAVA, AutoIt, PHP, or Perl to accomplish my task.
I should note that I am fairly new to ADO. the syntax in ADO seems to elude me frequently. so, any and all help is appreciated, please refrain from the "Just google it" responses. if you have a link to share, or a resource that you have found helpful please post that as well, I am not allergic to reading or doing research. Sometimes it just makes more sense to ask for help.
Thanks,
Kyle
If you are open to using VBA, you could probably make it work with only a little code and the DoCmd-Object.
To export as CSV, have a look at DoCmd.Transfertext
To export to dBase, have a look at DoCmd.TransferDatabase
If you have questions about using those, just ask in the comments and I will provide more information.
This is a sort of bonkers idea, but if you already know Java, you may be able to get this to work with the JDBC-ODBC bridge. You'll first have to register your particular Access database as a named ODBC data source, as the bridge does not appear to support on-the-fly ODBC. I don't have a Windows machine on hand and don't remember the exact sequence of steps to do that, but it should be available from the ODBC driver manager.

Categories

Resources