Login Form

The sotware we are going to use is:

 

Installing postgreSQL database in our local pc

1. Initialize a database cluster

Before we can do anything, we must initialize a database cluster. A database cluster is a collection of databases that is managed by a single instance of a running database server.

After initialization, a database cluster will contain a database named postgres, which is meant as a default database for use by utilities, users and third party applications.

 In our local pc, a database cluster will be a single directory under which all data will be stored. It is up to you where you choose to store your data.

 Sample directory:    C:\pgsqldb

 To initialize a database cluster, use the command initdb, which is installed with PostgreSQL. The desired file system location of your database cluster is indicated by the -D option, for example: 

      initdb -D C:\pgsqldb

 

  • Note that initdb also initializes the default locale for the database cluster.
  • and initdb also sets the default character set encoding for the database cluster.

 Tip: As an alternative to the -D option, you can set the environment variable PGDATA. Without -D, the server will try to use the data directory named by the environment variable PGDATA. If that variable is not provided either, it will fail.

 

2. Starting / stoping the database server

Before we can start working with any database, it is necessary to start the database Server:

      postgres -D C:\pgsqldb > C:\pgsqldb\logs\logfile.log 2>&1 &

and it can be stopped with this command:

      postgres -D C:\pgsqldb stop -m fast

 

All the steps we have seen before, can be integrated into a single .bat file (I do prefer this way):

@ECHO ON
REM The script sets environment variables helpful for PostgreSQL
@SET PATH="C:\pgsql\bin";%PATH%
@SET PGDATA=C:\pgsqldb
@SET PGDATABASE=postgres
@SET PGUSER=postgres
@SET PGPORT=5432
@SET PGLOCALEDIR=C:\pgsqldb\share\locale
REM "C:\pgsql\bin\initdb"
"C:\pgsql\bin\pg_ctl" -D "C:\pgsqldb" -l logfile start
ECHO "Click enter to stop"
pause
"C:\pgsql\bin\pg_ctl" -D "C:\pgsqldb" stop -m fast

  Note: The line that uses the initdb command, must be executed only one time. After that we can keep it commented. In my case, is taken my windows default user: jorgevs

 

 3. Creating the sonar database

To create the database, we will use the pgAdmin3 tool

       pgAdmin3.exe

 Once its window is open, we will need to configure certain values:

Once we are connected, we will create a sonar user:

the values will be:

      Role name: sonar

      Password: sonar

            

and now, we create the sonar database:

     

the values will be:

      Name: sonar

      Owner: sonar (the one we create previously)

      Encoding: UTF-8

      Template: Template0

 

Connecting our Database with SonarQube

1. Setting the access to the database

Edit <install_directory>/conf/sonar.properties to configure the database settings. Templates are available for every supported database. 

Just uncomment and configure the template you need and comment out the lines dedicated to H2

 #Example for PostgreSQL
sonar.jdbc.username=sonar
sonar.jdbc.password=sonar
sonar.jdbc.url=jdbc:postgresql://localhost/sonar

 

2. Adding the JDBC Driver

There is nothing to do in this step, since drivers for the supported databases (except Oracle) are already provided. Do not replace the provided drivers; they are the only ones supported.

Note: For Oracle, copy the JDBC driver into <install_directory>/extensions/jdbc-driver/oracle.

 

3. Starting the Web Server

The default port is "9000" and the context path is "/". These values can be changed in <install_directory>/conf/sonar.properties:

Execute the following script to start the server:

On Windows: bin/windows-x86-XX/StartSonar.bat         Select the StartSonar.bat file according to the JDK you are using (32 or 64 bits).

 Now, you can now browse SonarQube at http://localhost:9000 (the default SonarQube administrator credentials are admin / admin).

Note: The first time SonarQube is executed, the database tables will be created.

 

4. Tuning the Web Server

By default, SonarQube is configured to run on any computer with a simple Java JRE. The first thing to do when installing a production instance is to use a Java JDK and activate the server mode by uncommenting the following line in <install_directory>/conf/wrapper.conf:

wrapper.java.additional.3=-server    (do not uncomment in a local pc)

  

To change the Java JVM used by SonarQube, simply edit <install_directory>/conf/wrapper.conf and update the following line:

wrapper.java.command=wrapper.java.command=C:\jdk1.6.0_34_32Bits\bin\java

 

5. Update Sonar properties in Maven settings.xml

You'll need to add those lines to your Maven settings.xml file, so that once you execute your mvn sonar:sonar goal it will be able to register the metrics in your postgreSQL database.

01.<profile>
02.<id>sonar</id>
03.<activation>
04.<activeByDefault>true</activeByDefault>
05.</activation>
06.<properties>
07.<sonar.jdbc.url>jdbc:postgresql://localhost/sonar</sonar.jdbc.url>
08.<sonar.jdbc.driver>org.postgresql.Driver</sonar.jdbc.driver>
09.<sonar.jdbc.username>sonar</sonar.jdbc.username>
10.<sonar.jdbc.password>sonar</sonar.jdbc.password>
11.<!-- SERVER ON A REMOTE HOST -->
12.<sonar.host.url>http://localhost:9000</sonar.host.url>
13.</properties>
14.</profile>

 

6. Generating your application's SonarQube report

Execute the following maven command into the directory where your application's pom.xml file is located:

      mvn sonar:sonar

Once it has been executed successfully, you'll be able to check your application dashboard in SonarQube:

 

 

 

Comments   

0 #1 JUAN RODRIGUEZ 2015-11-29 16:39
Hola , me podrian ayudar con esto.

Soy Ingeniero Civil con conocimientos muy básicos de Java y necesito convertir unas coordenadas de un tipo a otras. Existe una página web donde digito las cordenadas en un sistema y ella me las arroja en el que necesito. El problema es que tengo que convertir mas de 500 cordenadas por lo que me gustaria saber como se podria iterar este proceso.

Add comment


Security code
Refresh

contacts Contactanos

 

bugs Reportar bugs

about Acerca de www.tecnohobby.net

Go to top