I am trying to create a simple application using Grails(3.2) and MySQL in Netbeans.
I have configured MySql in Grails project and also created a database, named "third" . After creating the domain class model, the controller (scaffolded) and the views for CRUD, my project is running but whenever I am trying to do any operation -
screenshot of error
this error is occuring. I am unable to solve this problem and also tried manually creating "Person" table, but same error occuring.
Your stacktrace clearly states that your db with name third doesn't have proper table person. But you shouldn't create this table manually (if you already had - please remove all tables from your db)
Connection seems fine but you should take a look at dbCreate value in your application.yml.
dbCreate - Whether to auto-generate the database from the domain model
- one of 'create-drop', 'create', 'update' or 'validate'
https://docs.grails.org/latest/guide/conf.html
If you are using just simple command grails run-app to start server, then you should check out the value in the environments: development block.
Paste your application.yml content (without db credentials) if you need a personalized solution.
Related
I have a project that is connected to an external database and just have view access to it. So I created my models with managed=False flag.
I was wondering how can I find out in django that any change in that database is happened. Is there any solution in django or I should find a method to communicate between that database and my django app. like socket, database triggers and ...?
More details:
Image my models is like this:
class Alert(models.Model):
key = models.CharField(max_length=20)
class Meta:
managed = False
Now i want to be notified in django each time the database is updated. I want a signal to capture database updates and do something in django?
my application creates PDF documents from html code. For that I put the print configuration with doctrine in a mysql database and call a commandline script which calls another symfony controller action with that printjob id.
Now the problem: I got the id right now after persisting the data, but the data isn't in mysql while first process is still running.
How can I tell doctrine, to write the data immediately in the database? I tried already tips like
$em->clear()
// or
$em->getConnection()->commit()
but I does not help or caused other problems.
try to flush the data with flush like:
$em->flush()
You can flush only a single entity:
$em->flush($object)
I'm building a multi tenant application with Grails and I want to keep separate databases.
I need to change the url dynamically at runtime to point GORM to different database.
I have a front-end acting as a balancer distributing requests to a cluster of backend hosts. Each backend host runs a Grails 2.3.5 instance and a mysql-server with several databases (one per tenant). I would like to change dataSource dynamically so that GORM can access domain entities on the right database.
Any ideas ?
Thanks
You can configure multiple data source in your DataSource.groovy, have a look in the blog.
In your domains: add which data source your domain can interact, eg.,
static mapping = {
datasources(['dataSource1', 'dataSource2'])
}
or "ALL" for all datasources, eg.,
static mapping = {
datasource 'ALL'
}
and then you can make queries with data source name to which you want to get/set data, eg.,
def userClass = User.class
User user = userClass.dataSource1.findByName('username')
Ref:- multipleDatasources, Querying on multiple datasource in grails
First Project: Spring3, Security3, Hibernate, MYSQL - How to install user tracking into database
I am working on my first project with Spring3, Security3, Hibernate, MYSQL.
I have the system working great I use Spring3 and Security3 goign to MySQL for the login and
using Spring3 MVC, Hibernate and MYSQL for system data.
I have a number of questions. Once I login does Spring Security save the user object somewhere that I can have
Hibrernate access it. I want Hibernate to put the user name or role into each insert to the database so as
I do my searches the system knows to only show data for that user and only that user?
this somes like it should be easy. Spring should be saving the user somewhere the hibernate can access.
please help me out
Once the user is authenticated, you can access the user's authentication session details:
Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
SecurityContext will allow you to grab the Authentication object, and from that you can retrieve the principal (an object representing the authenticated user), roles, etc. You could inspect this information and determine what data should be stored/displayed for each user.
If you can add a request filter or interceptor (the vocabulary may vary between frameworks), you could probably make these security checks abstract/generic enough to be applied across your entire web app (instead of adding a few lines of code to every resource method you're attempting to secure). Either way, SecurityContext should get you closer to what you want.
OK, Ive got my site all up - just not working. ahah. I need (I think) the correct code for a connection string to my database etc. I'm using ColdFsuion and Mysql. My code for the connection string is as follows:
<CFQUERY
NAME="cfGossip"
DATASOURCE="mysqlcf_bridgettip"
USERNAME="<bridgettip>"
PASSWORD="<*******>"
>
</CFQUERY>
My DNS on my hosting plan is, well I think is - mysqlcf_bridgettips and on my ColdFusion is cfGossip. I'm not sure which one to use, or if it's even one of them...? It says the error is there when I try access my index.cfm page.
The error over all is :
500 - Internal server error.
There is a problem with the resource you are looking for, and it cannot be
displayed.
Is it the connection string that is wrong? I would really love any help at all - rewriting my string etc.
Typically ColdFusion is easier to handle by adding datasources via the ColdFusion Administrator: See Adding Data Sources for ColdFusion.
if you cant access the coldfusion administrator and have no control panel to add a datasource you need to ask your host to add a datasource for you with a name. A datasource in this context is different from having the database created - its having the database "registered" with the coldfusion administrator so that it can be referenced via a datasource name
once the datasource is created you can hit it by adding the datasource attribute to the cfquery tag: cfquery name="myquery" datasource="mydatasourcename"
My DNS on my hosting plan is, well I
think is - mysqlcf_bridgettips and on
my ColdFusion is cfGossip.
The coldFusion Administrator should have a datasource that contains your mysqlcf_bridgettips information (CF datasource name, database name, server IP and port, username/password). If you've named that datasource cfGossip in the administrator than your cfquery should look like:
<cfquery name = "variableNameOfYourQuery (ex. qUsers)" datasource = "cfGossip">
I put my username/password in my datasource in the administrator so I don't have it written in my code.
I believe CF5 was the only version of CF that allowed DSN-less connections that would require a "connection string".