Play Framework Application and H2-browser - java

We have to develop an application using Java Play Framework 2. There is a simple database calling H2, and we can browse it using h2-browser command in play console, but if an application compiled with 'dist' command, we didnotget access to the play console, but we need to debug database. So how can we access h2-browser without play console in 'dist' compiled application.
Thank you for answer.
p.s. Sorry for poor english

Download and run the standalone H2 engine and connect to it using ServerMode (from both: Play and browser), link and samples available at H2 docs.
Note performance will drop while using TCP connection so back to Embed solution after debugging if that matters to you.

Related

How to connect a desktop java application and an online mysql database and execute query?

I am trying to create an desktop application for shop. I can create create desktop app and database individually but I dont know how to connect them and how to execute query from desktop. May be for executing query I should use php but I dont know how. My database have been created in hosting site using cpanel.
You need some kind of APIs on the server side. First learn about RESTful APIs and build your server accordingly. Decide a PHP framework to do this with ease.
Next design your desktop application in JAVA which has
Ability to connect to your APIs ( Give Credentials use OAuth2 or something.)
Store data locally and Sync it whenever Internet Connectivity is available ( Resolve conflicts when syncing )
This will need lots of research and efforts. Happy Coding!
This is a broad question. If you are using php to build a desktop application (which appears to be), you must download WAMP server for executing php scripts locally. But I recommend you making a desktop application using java swing or any other popular GUI-based programming language. Please go through MySQL using Java's JDBC tutorial . Also Google as the question has a quite broad scope.
Your Question is Vague But here is a tutorial on creating a Java Connection to a database.
http://www.homeandlearn.co.uk/java/connect_to_a_database_using_java_code.html

Run a simple Java program in the OpenShift cloud

what is the easiest method to run a Java program inside a gear on OpenShift?
I don't need a complex framework or web server. I just need a container to which I can upload my Java Files, compile and execute them in the cloud. The application I have in mind is very simple, a program that gathers some information and that I can connect to via RMI and just ask for the data.
Thanks.
If you don't need an application server you'd better take a look at DIY cartridge. You'd just have to create it from your code:
rhc app-create yourapp diy-0.1 --from-code git://github.com/(...).git
You could even use git hooks to launch it. Take a look at the hooks I use at my Wedding Tables Planner web, based in this template.
I think easiest is tu run a jbossas app and stop the jbossas cart if necessary. Otherwise you may play with the diy app type.

Java Code in Azure cloud service

I have java code (that generates jasper reports) and I couldn't convert it to .net and I want to run it on a "Cloud Services" how can I run java code into cloud service ?
any help will be appreciated
#Dhana provided a link to a tutorial for pushing a Java app to Azure in Cloud Services (worker role). You could also push to a Web role but it makes less sense since IIS runs in a Web role, and you'll probably want Jetty, Tomcat, or JBoss for your web server.
If you're running a console app, that's fine too - just launch it from a startup script or the OnStart() in your workerrole.cs.
You'll need to install the tooling into Eclipse. At this point, you'll be able to build Azure deployment packages, in a similar way to Visual Studio (The Azure plugin for Eclipse only works on Windows though). Part of the packaging sets up links to the appropriate JVM and web server package, as well as your own jar files.
If, say, you have a console app that listens on a port, you'll just need to make sure you have an input endpoint set up for the port you want to expose.

How do you access SQL database from GWT?

I've read some articles on the Internet that this is not possible. To communicate own SQL database that is located on other server from GWT application. Jetty doesn't allow it.
I found a way how to perform it but it's not very cosy. I have client and server part inside GWT. The server has to communicate with MySQL database on localhost. So I've written an ant script to build a war that I can launch on Apache Tomcat server. It works perfectly there but I'm not able to debug the code effectively.
Do you have some advices how to perform this task? I was thinking of writing the clienty only in GWT and find some waz how to communicate my own server written outside the GWT. I've found Apache Thrift for GWT but this edited library of thrift seem not to work properly.
Thank you very much for your answers:)
It is possible to communicate with a database from a GWT application. The client side has to call the methods of the server via GWT-RPC, which can communicate with any database.
Maybe Jetty does not support it (have not tested it personally) but you can develop your web application using Apache too. There you can access the database the same way as from any web application:
You will need the mysql-connector-java-5.1.20-bin.jar file (downloadable from: http://dev.mysql.com/downloads/connector/j/ ), and restart the server added to the $CATALINA_HOME/common/lib directory.
OR added to the WEB-INF/lib folder of your web application.
You can find tutorials online of how to develop an application using Tomcat instead of Jetty. For example: https://wiki.auckland.ac.nz/display/BeSTGRID/Deploying+GWT+to+Tomcat+in+Eclipse
Reshi, stop and think about how applications really work. Nobody provides web pages with javascript to read/write databases, that would be crazy and unsecure. Servers are always in themiddle of all communication in this case. You need to create services that run inside your server, one of these services will be a database layer.
Javascript cant create network connections and read/write binary data, thus it would be insane to attempt to get the gwt compiler to compile any jdbc drvier and more.
Jetty does NOT stop us from connecting to a database. All you have to do is to follow the MVP model way. Although MVP is better bet against all hurdles, at a minimal point, you would have to try not having SQL code on the client package.

Google App Engine Project works in Development Environment but not when Deployed

I am in the process of moving my web website over to google app engine and am having a problem with my site when it is deployed. The application was being hosted on tomcat/mysql and predominately consists of jsp pages. I have read the fallowing google documentation:
http://code.google.com/appengine/docs/java/config/webxml.html
I am unable to get any of the jsp pages to work correctly I keep getting a 500 Server Error
Error: Server Error
The server encountered an error and could not complete your request.
The project works great in the google app engine development environment but doesn't work when deployed it seems like the project isn't getting mapped.
Does anyone have any insight.
When your app raises an uncaught exception, App Engine shows the generic 500 page. In order to see the exception, you need to check the logs for your app in your app's admin console.
So after plenty of research I found the problem to be that some classes that are persisted need to also implement Serializable when you use sessions. For some reason I didn't see this in the documentation or come across it in my initial research.
I guess you have already done this, but you should be able to check if everything is fine locally, by first deploying locally using the app engine development server. http://code.google.com/appengine/docs/java/tools/devserver.html
If you're testing locally on tomcat + mysql, then you can't deploy on the app engine. The Google App Engine not does support SQL databases. Besides that, if you want a more detailed response you need to look at the app engine logs and tell us why it is throwing a 500 at you.

Categories