I have the db and current jar postgresql-9.4.1207.jre7.j to conect.
Now, from GGST im unable to find the option to add my jar.it seems to be similar to maven but still cant find the option
Finally i wonder if the driverClassName should be org.postgresql.Driver
dataSource {
pooled = true
driverClassName = "org.postgresql.Driver"
username = "root"
password = "root"
}
With Grails you don't actually add the jar. Instead, you declare the dependency in build.gradle (for Grails 3). For example, in the dependencies closure add the Maven artefact for postgresql like this:
dependencies {
...
compile 'org.postgresql:postgresql:9.4.1207.jre7'
}
For Grails 2 the concept is the same except the file is grails-app/conf/BuildConfig.groovy.
Related
Grails 4.0.10. Mongodb 5.0.9 Community.
I'm following the instructions at https://gorm.grails.org/latest/mongodb/manual/ with a Grails Plugin project.
First anomaly, build.gradle:
compile 'org.grails.plugins:mongodb:7.3.0'
Once I do this I get dependency errors and also have to add
compile 'org.mongodb:mongodb-driver-core:4.7.0'
compile 'org.mongodb:mongodb-driver-sync:4.7.0'
Ok, everything else is pretty much a vanilla project. I created a test domain class "QtxResponse" as
#Entity
class QtxResponse {
static mapWith = "mongo"
String objectId
static constraints = {
}
static mapping = {
//id column: "object_id"
objectId index: true
}
}
The project fires up without error. Using the console I create a new QtxResponse via create-domain-class with a String objectId property and try to save it. This is what I get:
java.lang.IllegalStateException: Either class [domainobject.qualtrics.QtxResponse] is not a domain class or GORM has not been initialized correctly or has already been shutdown. Ensure GORM is loaded and configured correctly before calling any methods on a GORM entity.
What is this telling me? Is it something with Gorm setup or something with mapping to mongodb? I have tried both with and without Hibernate.
For Grails 4.0.10, this configuration worked (with hibernate):
compile 'org.grails.plugins:mongodb:6.1.7'
compile 'org.mongodb:bson:4.7.0'
compile "org.grails.plugins:hibernate5"
compile "org.hibernate:hibernate-core:5.4.0.Final"
compile "org.hibernate:hibernate-ehcache:5.1.3.Final"
i tried to make a
liquibase xml with liquibase diff
command.
I want to do this based on this documentation: http://www.liquibase.org/documentation/diff.html
If I try to exec the example command with my custom properties,
with
--driver:org.postgresql.Driver,
I got this problem:
"Unexpected error running Liquibase: java.lang.RuntimeException:
Cannot find database driver: org.postgresql.Driver"
You have to specify the classpath where the driver jar file is located using the classpath key (liquibase documentation).
Your properties file should look like:
driver: org.postgresql.Driver
classpath: postgresql-driver.jar
url: jdbc:postgres#localhost:5432
username: scott
password: tiger
I have a problem with PK generation strategy in cayenne.
I'm using PostgreSQL 9.6 with Apache Cayenne 4.0.B1.
This is my table in postgres:
create table ui_template (
id varchar(50) primary key default uuid_generate_v1(),
path varchar(300) not null,
type varchar(50) not null
);
Then I'm doing Tools -> Reengineer Database Schema in Cayenne Modeler.
I got table and enity.
And now i have to set PK Generation Strategy to Database-Generated, to let DB generate my PK's. Everything works fine when I'm inserting objects through ObjectContext. But, if I'm running gradle task cdbimport it overwrites my datamap.map.xml file with another one without Generation Strategy.
Please give me advice what I'm doing wrong.
This is my gradle task
buildscript {
// add Maven Central repository
repositories {
mavenCentral()
}
// add Cayenne Gradle Plugin
dependencies {
classpath group: 'org.apache.cayenne.plugins', name: 'cayenne-gradle-plugin', version: '4.0.B1'
classpath group: 'org.postgresql', name: 'postgresql', version: '42.1.3'
}
}
// apply plugin
apply plugin: 'org.apache.cayenne'
// set default DataMap
cayenne.defaultDataMap 'resources/datamap.map.xml'
// add Cayenne dependencies to your project
dependencies {
// this is a shortcut for 'org.apache.cayenne:cayenne-server:VERSION_OF_PLUGIN'
compile cayenne.dependency('server')
compile cayenne.dependency('java8')
}
cdbimport {
dataSource {
driver 'org.postgresql.Driver'
url 'jdbc:postgresql://localhost:5432/my_db'
username 'user'
password 'pass'
}
}
You are doing nothing wrong, it seems that you found a weak spot in cdbimport.
In your case Cayenne doesn't understand default values, for Postgres DB Cayenne marks only serial columns as db-generated.
You can either change your PK to serial (unless you have some special requirements it is always a good idea) or you can try to exclude those PKs from cdbimport task like this:
cdbimport {
//...
includeTable 'ui_template', {
excludeColumns 'id'
}
}
Be aware that excluding PKs can lead to problems with importing relationships. And moreover if you use includeTable you should explicitly list all required tables.
my input: a collection("demo1") in mongo db (version 3.4.4 )
my output : my data imported in a database in hive("demo2") (version 1.2.1.2.3.4.7-4)
purpose : create a connector between mongo and hive
Error:
Execution Error, return code 1 from org.apache.hadoop.hive.ql.exec.DDLTask. com/mongodb/util/JSON
I tried 2 solutions following those steps (but the error remains):
1) I create a local collection in mongo (via robomongo) connected to docker
2) I upload those version of jars and add it in hive
ADD JAR /home/.../mongo-hadoop-hive-2.0.2.jar;
ADD JAR /home/.../mongo-hadoop-core-2.0.2.jar;
ADD JAR /home/.../mongo-java-driver-3.4.2.jar;
Unfortunately the error doesn't change; so I upload those version, I hesitate in choosing right version for my export, so I try this:
ADD JAR /home/.../mongo-hadoop-hive-1.3.0.jar;
ADD JAR /home/.../mongo-hadoop-core-1.3.0.jar;
ADD JAR /home/.../mongo-java-driver-2.13.2.jar;
3) I create an external table
CREATE EXTERNAL TABLE demo2
(
id INT,
name STRING,
password STRING,
email STRING
)
STORED BY 'com.mongodb.hadoop.hive.MongoStorageHandler'
WITH
SERDEPROPERTIES('mongo.columns.mapping'='{"id":"_id","name":"name","password":"password","email":"email"}')
TBLPROPERTIES('mongo.uri'='mongodb://localhost:27017/local.demo1');
Error returned in hive :
Execution Error, return code 1 from org.apache.hadoop.hive.ql.exec.DDLTask. com/mongodb/util/JSON
How can I resolve this problem?
Copying the correct jar files (mongo-hadoop-core-2.0.2.jar, mongo-hadoop-hive-2.0.2.jar, mongo-java-driver-3.2.2.jar) on ALL the nodes of the cluster did the trick for me.
Other points to take care about:
Follow all steps mentioned here religiously - https://github.com/mongodb/mongo-hadoop/wiki/Hive-Usage#installation
Adhere to the requirements given here - https://github.com/mongodb/mongo-hadoop#requirements
Other useful links
https://github.com/mongodb/mongo-hadoop/wiki/FAQ#i-get-a-classnotfoundexceptionnoclassdeffounderror-when-using-the-connector-what-do-i-do
https://groups.google.com/forum/#!topic/mongodb-user/xMVoTSePgg0
I am having an issue where I need to manually map the correct database to the domain instead of it being picked up from the connection argument.
I am using grails 3.2.8, plugin "org.grails.plugins:mongodb:6.1.0". I have both hibernate and mongodb plugin enabled.
I have define my connection URL as
//application.yml
mongodb:
url: 'mongodb://${MONGODB_USERNAME}:${MONGODB_PASSWORD}#${MONGODB_REPLICA_SET}/${MONGODB_DATABASE}?${MONGODB_CONNECTION_OPTIONS}'
My domain object is defined as :
class ReportData {
String id
Long someField
static mapWith = "mongo"
static mapping = {
//database "db-name" DOESN'T WORK WHEN COMMENTING OUT THIS LINE
}
}
Shouldn't the database(system property MONGODB_DATABASE) be picked up auto-magically from the connection url? I am not sure if this is a bug or I am missing some configuration aspect.
I realized that I had not added following in my build.gradle file:
bootRun {
systemProperties = System.properties
}
so my application environment settings were not even getting applied correctly and hence my connection url was invalid.
I found that detail here: http://docs.grails.org/latest/guide/conf.html