There are so many horror stories about postgres and Play framework here on SO and on blogs.
So I am wondering does Play 1.2.4, scala and anrom(magic) work with postgres or not.
In my test case I get the following when switching to Postgres.
The db is correctly created by 1.sql in evolutions. And the log prints Connected to jdbc:postgresql://localhost/postgres_play
Anorm works just fine with postgresql, we're currently converting a complex postgresql based app from PHP to play with scala and have had no DB related issues at all. As to your error, I'm not 100% certain but it may be simply that it is looking for the table "Player" and you have the table "player" in your database. Show us the code where you are defining the Player object that extends magic.
Related
I'm working on Java with an application that persists in Oracle and PostgreSQL (not at the same time). I'd like to get the type of the database that is currently running because I need to work in a different way depending on whether it's oracle or it's Postgresql.
JDBC API should help: getDatabaseProductName(). There are other methods as well that allow to get the product version and the driver name and its version.
I would like to know which alternatives exist to replace DDL utils from Apache.
I ask this because ddlutils project seams to be Dead, and also it does not support H2 Databases. I've searched for it, and I found suggestions like liquidbase or flyway.
My problem is: These frameworks run when project starts and change DB structure based on some XML files. They are really designed for Database Migration.
What I want is a framework to CREATE/ALTER Tables in Runtime, in a high abstraction level., i.e. supportting at least Mysql, Sqlserver, oracle, and H2.
For example I could tell to the engine that I want to create a table with a Field AGE with Type Number, and the framework would rephrase to:
create table MY( id bigint(20))
create table MY(id bigint)
create table MY (id, number)
depending on the underlying db engine.
Any suggestions?
I could see there is a patch for ddlutils, for it to support H2. However I wasn't able to patch my svn checkout...
Any help will be appreciated.
thanks in advance
rui
I know this is an old thread, but wanted to give a definitive answer.
Yes, DdlUtils is dead, hasn't seen an update in 2 years now.
However, it looks like the guys might have switched over to https://www.symmetricds.org. Their repo is https://github.com/JumpMind/symmetric-ds.
As soon as you scratch away at the surface, you'll find that the core of DdlUtils is still in there (even has some of the old Apache copyright notices).
Class names have changed, APIs have changed so there is not a 1-to-1 mapping, but it is getting regular updates and includes H2 and other database support. Honestly I'd rather be getting those things instead of keeping the old APIs.
You're not going to find a guide on using Symmetric DS in the same way as the old DdlUtils doco, but there is enough in the code that you should be able to piece it together.
Take a look on jOOQ it is very useful in generating DDL (and DML too)
create.createTable("table")
.column("column1", INTEGER)
.column("column2", VARCHAR(10).nullable(false))
.constraints(
constraint("pk").primaryKey("column1"),
constraint("uk").unique("column2"),
constraint("fk").foreignKey("column2").references("some_other_table"),
constraint("ck").check(field(name("column2")).like("A%"))
)
.execute();
This looks promising: https://bitbucket.org/aragot/play-sql-dialects/src
At least as a start.
Mogwai ERD designer might help though they do not formally support H2 but you could put H2 into compatibility mode with one of the supported DB systems: https://sourceforge.net/p/mogwai
i am new in playframework i know how to install playframework and connect it to the database . Is there is any tutorial for that like how to perform sql operation using java in playframework.
SQL is not dependent on the Play Framework; it's dependent on the database you choose to use as a store for your Play Framework application.
W3 Schools has a pretty good tutorial for basic SQL operations. You can also look up additional commands and functionality provided by your specific database provider in the docs for that database. e.g. look here if you've chosen to use a version of PostgreSQL
The problem is confused slightly in that what I think you need is a method for your application to map rich application objects to flat database tables. This task can be done using an Object-Relationship-Mapping or functional-mapping tool. Ebean is an example of an ORM and Slick is an example of a functional mapping tool, both of which can be used in Play applications by adding their drivers to your /project/build.scala file in the list of your project dependencies.
Setting up Ebean for your Java-based Play project is covered on the page of the Play 2.1 Java tutorial after the one linked to by bistros - Using the Ebean ORM
see playframework.com tutorial page.
http://www.playframework.com/documentation/2.1.x/Installing
http://www.playframework.com/documentation/2.1.x/JavaDatabase
You can start direct with examples from the website. I think this one is very nice to understand how to work with database.
play-java-ebean-example
I have with me a java app that uses mysql-- now I have converted the database to SQL Server- but I need to convert the code of the java app so that it now uses SQL Server.
This java app uses Struts and Hibernate
What all things do I have to keep in mind to make this conversion?
hibernate should make the transition seamless for you.
Make sure to choose the correct driver as some drivers might act differently.
I personally like jtds. It has vast documentation.
Look for native queries in your code because they might need some modifications.
Other than that, I don't think you should experience any problem.
I had an application that supported oracle, SQL-Server and mysql and we didn't have specific code for each one.
EDIT : as maba suggests in the comments, you will need to modify the hibernate configuration a bit (driver, dialect, url ).
For more hibernate specific configuration, I found a great stackoverflow answer
I have prepared an application that is a small demo of Student information manipulation. I have stored information related to students in a MySQL DB. Now my application is working 100% on my computer. But I want that work everywhere without depending on Database! I mean I just want "WHEREVER MY .JAR FILE GOES, DATABASE SHOULD ALSO GO ALONG WITH THAT INSIDE .JAR FILE "
So anyone who is using my application or trying it, they can realize exact result of this application.
How can I make this possible? Please someone help me.
You will probably need to look at something like HyperSQL, which is a in-memory database (which you will need to populate at application start-up). Or have a look at SQLite, which is an embedded databsase, which you can distribute as a resource in your jar.
This doesn't work. MySQL is a full-blown RDBMS. You would have to install it on every computer if you want application to use it locally. An alternative would be using SQLite.
SQLite is a software library that implements a self-contained, serverless, zero-configuration, transactional SQL database engine.
SQLite and Java
SQLite seems to be a good fit for your requirements.