There are a number of application that work well on there own and are great for the purpose they are designed for. However everything links together some how and understanding how applications work on their own is only the start of things.
Whilst I have been learning about a number new applications, I have also been looking at how applications can work with each other to give an end to end feel of how certain Internet businesses or back end technologies really work.
There are hundreds or some times thousands of different way in which applications can link with each other within a business or over the Internet. Whether it be using a different storage database at the back end or it be writing a front end client in a different language, I have been documenting a number of working solutions already in my blog http://vidorsolutions.com
Some of the technologies I have learnt and experimented successfully with are as follows:
1. Grails application deployed into Glassfish application server, using PostgreSQL as a database. Then using tools such as PGAdmin to connect to my databases locally on my machine.
2. Ejabberd Instant Messaging server installed on a server instance in the cloud, configured to use postgreSQL as a data source. Then using PSI Desktop chat client to connect with Ejabberd account. Tools such as PGAdmin can also be used here to view the back end database, tables and structure.
To further extend this learning experience I then created a basic Android XMPP client application that could also connect to the Ejabberd Server instance.
A lot of different technologies going on here and a lot to learn about the applications alone if you've never used any of these. However once you see how all these work together you get a greater appreciation of how the end to end user experience works.
Remember for some instructions on how to use these check out my previous posts
http://vidorsolutions.com
Showing posts with label grails. Show all posts
Showing posts with label grails. Show all posts
Wednesday, 19 January 2011
Sunday, 2 January 2011
Using PostgreSQL database driver within your Grails applications
By default Grails uses an in-memory database that stores data for your apps within volatile RAM. You can leave this as it is but most programmers like to know that their database is more peristent.
In order to use your own data sources you need to be looking at the DataSource.groovy file within /grails-app/conf directory. Here you specify the database that your application will use.
There are three sections within this file so you can specify different data sources for different purposes: production, test and development. In the example I will demonstrate using a different PostgreSQL database for each purpose however you can use three entirely different products if you wish.
Before you start configuring anything in the DataSource.groovy file ensure that you have completed the following:
1. Ensure PostgreSQL is installed
2. Download PostgreSQL JDBC driver and save it into your applications lib folder.
3. Ensure you have a PostgreSQL user to use for the database connection. If you do not wish to use default user, create new user with createuser command.
4. Create the relevant databases in PostgreSQL that your grails application will use. This can be done simply though PGAdmin or using createdb commands as the PostgreSQL user.
5. Return to the Datasource.groovy config file and use the following settings:
dataSource {
pooled = true
driverClassName = "org.postgresql.Driver"
username = "postgres"
password = "password"
}
hibernate {
cache.use_second_level_cache=true
cache.use_query_cache=true
cache.provider_class='org.hibernate.cache.EhCacheProvider'
}
// environment specific settings
environments {
development {
dataSource {
dbCreate = "update" // one of 'create', 'create-drop','update'
url = "jdbc:postgresql://localhost:5432/devdb"
}
}
test {
dataSource {
dbCreate = "update"
url = "jdbc:postgresql://localhost:5432/testdb"
}
}
production {
dataSource {
dbCreate = "update"
url = "jdbc:postgresql://localhost:5432/proddb"
}
}
}
Please note that the following are examples of the different database purposes:
In order to use your own data sources you need to be looking at the DataSource.groovy file within /grails-app/conf directory. Here you specify the database that your application will use.
There are three sections within this file so you can specify different data sources for different purposes: production, test and development. In the example I will demonstrate using a different PostgreSQL database for each purpose however you can use three entirely different products if you wish.
Before you start configuring anything in the DataSource.groovy file ensure that you have completed the following:
1. Ensure PostgreSQL is installed
2. Download PostgreSQL JDBC driver and save it into your applications lib folder.
3. Ensure you have a PostgreSQL user to use for the database connection. If you do not wish to use default user, create new user with createuser command.
4. Create the relevant databases in PostgreSQL that your grails application will use. This can be done simply though PGAdmin or using createdb commands as the PostgreSQL user.
5. Return to the Datasource.groovy config file and use the following settings:
dataSource {
pooled = true
driverClassName = "org.postgresql.Driver"
username = "postgres"
password = "password"
}
hibernate {
cache.use_second_level_cache=true
cache.use_query_cache=true
cache.provider_class='org.hibernate.cache.EhCacheProvider'
}
// environment specific settings
environments {
development {
dataSource {
dbCreate = "update" // one of 'create', 'create-drop','update'
url = "jdbc:postgresql://localhost:5432/devdb"
}
}
test {
dataSource {
dbCreate = "update"
url = "jdbc:postgresql://localhost:5432/testdb"
}
}
production {
dataSource {
dbCreate = "update"
url = "jdbc:postgresql://localhost:5432/proddb"
}
}
}
Please note that the following are examples of the different database purposes:
- Development db is when you use grails run-app to launch you application
- Test db is when you run grails unit and integration tests
- Production db is used when you upload the application to an app server such as glassfish etc.
Labels:
application,
database,
driver,
grails,
jdbc,
postgresql,
proddb
Monday, 13 December 2010
Writing your first Grails Application
Writing your first grails application without the use of an IDE. Ensure grails is installed by running grails from a command prompt, then continue with the steps below to create your first app.
http://www.grails.org/Quick+Start
http://www.grails.org/Quick+Start
Tuesday, 30 November 2010
Installing Grails on Linux
Before installing or using Grails, set JAVA_HOME environment variable:
1. Add the following to ~/.profile
export JAVA_HOME=/usr/local/jdk1.6.0_27/
export PATH=$PATH:/usr/local/jdk1.6.0_27/bin
Location will be where JDK is installed to.
2. Log out and back in again, run echo $JAVA_HOME and echo $PATH to confirm. Also check by typing java -version.
To install Grails:
1. Download grails from http://www.grails.org/Download
2. Extract the archive into a home directory. Typically /usr/local in Linux
3. Append a reference to grails as a variable, as with JAVA_HOME above
export GRAILS_HOME=/usr/local/grails-1.3.7/
export PATH=$PATH:/usr/local/grails-1.3.7/bin
Location path will be the directory you saved the extracted files to.
4. Log out and back in again.
5. Type grails in a terminal window to test. You should see:
Welcome to Grails 1.3.5 - http://grails.org/
Licensed under Apache Standard License 2.0
Grails home is set to: /home/lee/grails-1.3.5
No script name specified. Use 'grails help' for more info or 'grails interactive' to enter interactive mode
You can now begin writing grails applications
1. Add the following to ~/.profile
export JAVA_HOME=/usr/local/jdk1.6.0_27/
export PATH=$PATH:/usr/local/jdk1.6.0_27/bin
Location will be where JDK is installed to.
2. Log out and back in again, run echo $JAVA_HOME and echo $PATH to confirm. Also check by typing java -version.
To install Grails:
1. Download grails from http://www.grails.org/Download
2. Extract the archive into a home directory. Typically /usr/local in Linux
3. Append a reference to grails as a variable, as with JAVA_HOME above
export GRAILS_HOME=/usr/local/grails-1.3.7/
export PATH=$PATH:/usr/local/grails-1.3.7/bin
Location path will be the directory you saved the extracted files to.
4. Log out and back in again.
5. Type grails in a terminal window to test. You should see:
Welcome to Grails 1.3.5 - http://grails.org/
Licensed under Apache Standard License 2.0
Grails home is set to: /home/lee/grails-1.3.5
No script name specified. Use 'grails help' for more info or 'grails interactive' to enter interactive mode
You can now begin writing grails applications
Subscribe to:
Posts (Atom)