Cannot connect to the database with Play framework - java

I'm building a website with play! framework, I've finished coding and testing with in memory database, and everything was fine, so I decided to push the code to my server. But I encountered with a strange error, it says, "A database error occured : Cannot connected to the database, Unknown database 'fpn_server'".
I did change the application.conf file in conf folder, I set the application.mode to prod(quite sure this has no connection with database), set the db property to "mysql:root:mypass#fpn_server", and jpa.ddl to "create" to make sure the database got created.
Well, to be honest, I developed a demo website with the same database name, and it was successfully deployed on my server. But this time, the schema changed, I did NOT use the evolution scripts as the documentation said, I simply dropped the database from mysql server. Not quite sure if this is the mistake.
I've been googling around for a while, an no good.
BTW, I'm usin play 1.2.4 not play 2.
Can anyone help me? Any suggestion is welcome!
Thanks in advance.

You are using the shortcut MYSQL5 configuration, which appears fine. However, maybe you should try using the verbose settings.
%production.db.url=jdbc:mysql://localhost/fpn_server
%production.db.driver=com.mysql.jdbc.Driver
%production.db.user=root
%production.db.pass=mypass
If there is anything that looks wrong in the verbose settings, this could be responsible for why your shortcut settings are not making sense.
If the configuration looks fine, I would check that your database is accessible.
For reference, here is the application.conf database options - http://www.playframework.org/documentation/1.2.4/configuration#dbconf

Related

H2 tables not showing up in IntelliJ for Jhipster generated project

So I generated a new Spring boot application using jhipster. Upon navigating to the H2 console, the following information is shown.
I am able to login, and I can verify tables exist.
Next, I copy the link, jdbc:h2:file:./target/h2db/db/ikdoemee and try to connect to the H2 database using IntelliJ which shows successful.
However, the IntelliJ database view isn't showing any tables.
I tried adding the following parameters to my JDBC url, but no tables show up.
jdbc:h2:file:./target/h2db/db/ikdoemee;AUTO_SERVER=TRUE;DB_CLOSE_DELAY=-1 ;DATABASE_TO_UPPER=false
Why am I unable to get my tables visible in IntelliJ?
My .h2.server.properties is
#H2 Server Properties
0=JHipster H2 (Disk)|org.h2.Driver|jdbc\:h2\:file\:./target/h2db/db/ikdoemee|ikdoemee
webAllowOthers=true
webPort=8082
webSSL=false
EDIT: My target folder:
You need to activate h2 "Automatic Mixed Mode" by changing the spring.datasource.url of the application-dev.yml file.
example URL: jdbc:h2:./target/h2db/db/'PROJECTNAME';AUTO_SERVER=TRUE
The URL for the connection to the h2 database should look like that:
jdbc:h2:/home/'USERNAME'/IdeaProjects/'PROJECT'/target/h2db/db/'PROJECTNAME';AUTO_SERVER=TRUE
if that doesn't work try also to delete the target folder and refresh the h2 connection
To resolve this issue I installed Buddy JPA plugin.
It created profile automatically and I compared it with mine.
the difference was in parameter DB_CLOSE_ON_EXIT=FALSE
I tried it with manually created profile and it works as well.
The result link is:
jdbc:h2:file:./work/h2db;DB_CLOSE_ON_EXIT=FALSE
The only solution that worked for me at the moment is to put the direct path to the file in Path field without extension.
After that I could see my tables in IDEA.
click to preview settings
Note:
Don't forget to also add parameter AUTO_SERVER=TRUE to datasource.url, as pointed out by #Unknown_Energy.
My apps versions:
Idea 2018.3.5 UE
h2 1.4.197
h2 base name: demo.mv.db
this bug is related to these issues:
Data Source detection
Intellij IDEA and H2 DB file recognition problem
When running the application, the log will show something like
n.w.config.DatabaseConfiguration 1: H2 database is available on port 18080.
Then change Connection Type to Remote and port to the port just showed,
append the db file location to the url (with out extension) just like ./build/h2db/db/projectname, User will be the ProjectName.
The final url will like jdbc:h2:tcp://localhost:18080/./build/h2db/db/projectname
This worked for me, I'm not a English native speaker, sorry for my poor English.

Connecting your application with database

I'm pretty beginner with AndroidStudio and java, I know the basics and some additional stuff and how generally java works but.
...creating applications from nothing in java is hard ._.
What I would like to do is :
-I have created a database on my personal computer with the data I need (id, logins and passwords)
I would like to make a very simple app in AndroidStudio, that's important, that would check login and password and display success on login and fail if fail.
I have already created a php script and put it into a simple html website, everything works perfectly but when it comes to an application....oof.
tl;dr
I would need help how to make a simple login system in AndroidStudio and would use the app to log in to my database on my pc (both connected to same network)
Thanks for reading.
an easy begginer approach will be to first add apache dependency in your app:module file then make http requests. Check this sample. https://www.learn2crack.com/2016/04/android-login-registration-php-mysql-client.html

connecting with JBOSS EAP to H2 Console (Red Hat - Ticketmonster tutorial )

I'm doing the Red Hat TicketMonster tutorial but got stuck pretty fast.
You can find the tutorial (pdf) here
The problem:
At first everything worked just fine. I managed to deploy the app on localhost, could see the tables using h2console etc.
But when I decided to continue later, I couldn't enter the console like I did before. So I installed the H2 database engine and am able to at least log in but now my tables are gone.
I didn't change anything in the -ds.xml file (just added some Entities in the model package) and use the same url in the database engine.
Maybe the database is locked?
<connection-url>jdbc:h2:mem:test;DB_CLOSE_ON_EXIT=FALSE;DB_CLOSE_DELAY=-1</connection-url>
I don't know what went wrong and what to do next.
Never mind, found the reason why the connection to h2 console didn't work.
Apparently I didn't deploy the h2console.war in the right folder after changing the runtime server (to Wildfly).

restore derby database online

From a java application (junit test) I am trying to restore a derby file database. The derby server has been started as a standalone server (so not embedded). I am using the following code.
String url = "jdbc:derby://localhost/V4_0_0/ambikas";
String urlToRestoreFrom = "C:/javadev/workspace/trunk/ambi-kas-lib/derby/V4_0_0_backup/ambikas";
DriverManager.getConnection(url + ";createFrom=" + urlToRestoreFrom);
log.debug("db restored ...");
When I run the code no exceptions are thrown from Derby's side. Everything seems to go fine but no restore has taken place. The directory "url" where I want to restore the db contains the current database. According to the derby documentation this should work however. The restore functionality should replace the current db.
I know there have been some threads before on this topic but none of them seem to solve my problem. I am stuck with it for weeks now.
It's not "createFrom=", it's "restoreFrom=".
See these docs for more information: http://db.apache.org/derby/docs/10.9/adminguide/cadminhubbkup98797.html

Apache Derby - Database created but not found

This is in continuation to my previous question
I'm trying to embed a derby database in my web application. I'm able to embed it, though I am facing glitches. Here's the snapshot of my project structure.
I wonder why class.forName("org.apache.derby.jdbc.EmbededDriver") is throwing exception?
java.lang.ClassNotFoundException: org.apache.derby.jdbc.EmbededDriver
To overcome this, I have used
DriverManager.registerDriver(new org.apache.derby.jdbc.EmbeddedDriver());
Which works well. Why is it so? Also, Where would it create database if coded like this. I cannot spot the database.
connection = DriverManager.getConnection("jdbc:derby:MyDbTest;create=true");
I checked in tomcat webapps and eclipse workspace, I didn't find database.
If given this way, I can spot it.
connection = DriverManager.getConnection("jdbc:derby:E:/MyDbTest;create=true");
class.forName("org.apache.derby.jdbc.EmbededDriver")
Threw an exception because there is a 'd' missing from embedded.
See here for information about specifying the location of databases on the file system.
connecting to a file-based derby database

Categories