Hibernate-SQLite how to add in Java project

http://code.google.com/p/hibernate-sqlite/

1.add repository in the pom.xml file(between the repositories tag)

1
2
3
4
<repository>
  <id>hibernatesqlite-maven</id>
  <url>https://hibernate-sqlite.googlecode.com/svn/trunk/mavenrepo</url>
</repository>

2.add dependency in the pom.xml file(between the dependencies tag)

1
2
3
4
5
6
<!-- hibernate sqlite dialect -->
<dependency>
  <groupId>com.applerao</groupId>
  <artifactId>hibernatesqlite</artifactId>
  <version>1.0</version>
</dependency>

3.modify the hibernate dialect configuration like:

1
<property name="dialect">com.applerao.hibernatesqlite.dialect.SQLiteDialect</property>

4.maven your project and the hibernate-sqlite is ready to use.

Additionally, the version of hibernate used in hibernatesqlite-1.0 is 3.2.6.ga, and if you want to use another version of hibernate, you can exclude the hibernate like this:

1
2
3
4
5
6
7
8
9
10
11
12
<!-- hibernate sqlite dialect -->
<dependency>
        <groupId>com.applerao</groupId>
        <artifactId>hibernatesqlite</artifactId>
        <version>1.0</version>
        <exclusions>
                <exclusion>
                        <groupId>org.hibernate</groupId>
                        <artifactId>hibernate</artifactId>
                </exclusion>
        </exclusions>
</dependency>

and add hibernate dependency like this:

1
2
3
4
5
6
<!-- hibernate jars -->
<dependency>
  <groupId>org.hibernate</groupId>
  <artifactId>hibernate</artifactId>
  <version>3.2.7.ga</version>
</dependency>

YMaps sample broken dashed line

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
< !DOCTYPE html>

<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>Примеры. Размещение карты на странице.</title>
    <!--
       Подключаем API карт
       Параметры:
         - load=package.standard - основные компоненты;
          - lang=ru-RU - язык русский.
   -->
    <script src="http://api-maps.yandex.ru/2.0/?load=package.full&lang=ru-RU" type="text/javascript"></script>

<script type="text/javascript">
var myMap;

// Дождёмся загрузки API и готовности DOM.
ymaps.ready(init);

function init () {
    // Создание экземпляра карты и его привязка к контейнеру с
    // заданным id ("map").
    var myMap = new ymaps.Map('map', {
        // При инициализации карты обязательно нужно указать
        // её центр и коэффициент масштабирования.
        center:[55.76, 37.64], // Москва
        zoom:17
    });
   
    // Ломаная
    var myPolyline = new ymaps.Polyline([
        // Координаты вершин ломаной.
        [55.7599, 37.6375],
        [55.759800, 37.6402],
        [55.7606, 37.6403]
    ], {
        hintContent: "ОСПД-8А"
    }, {
        strokeWidth: 5, // ширина линии
        draggable: true,
        // Первой цифрой задаем длину штриха. Второй цифрой задаем длину разрыва.
        strokeStyle: '2 2'
    });
   
    //alert(1);
    myMap.geoObjects.add(myPolyline);
   
    document.getElementById('destroyButton').onclick = function () {
     
        // Для уничтожения используется метод destroy.
        myMap.destroy();
    };

}
</script>
</head>

<body>
    <div id="map" style="width:600px; height:300px"></div>
    <input type="button" id="destroyButton" value="Удалить карту"/>
</body>

</html>

Continue reading

create certificates

создаем сертификат и ключ :

1
2
3
4
5
6
7
cd /etc/ssl/

openssl genrsa -out ip209-253.dreamteam7.com.key 2048

openssl req -new -key ip209-253.dreamteam7.com.key -out ip209-253.dreamteam7.com.csr

openssl x509 -req -days 3650 -in ip209-253.dreamteam7.com.csr -signkey ip209-253.dreamteam7.com.key -out ip209-253.dreamteam7.com.csr

http://www.opennet.ru/base/net/apache_mod_ssl.txt.html

порядок действий СОЗДАЕМ сертификат для домена. и подписываем НАШИМ CA.ROOT :

на сервере :

1
2
3
4
5
6
cd /etc/ssl
export MYDOMAIN=mysql.wm.com.ru
openssl req -config ./ca.config -new -keyout $MYDOMAIN.req.pem -out $MYDOMAIN.req.pem  -days 10000
openssl ca -config ./ca.config -policy policy_anything -out $MYDOMAIN-cert.pem  -infiles $MYDOMAIN.req.pem

openssl rsa -in $MYDOMAIN.req.pem -out $MYDOMAIN-wwwkeyunsecure.pem

– создать privat key (newreq.pem) для запроса его подписи
openssl req -config ./ca.config -new -keyout $MYDOMAIN.pem -out $MYDOMAIN.pem -days 3650

– First strip the certificate from all its text to keep only the -CERTIFICATE- section
openssl x509 -in $MYDOMAIN.pem -out $MYDOMAIN.crt

– подписываем нашим CA-ROOT сертификатом
openssl ca -config ./ca.config -policy policy_anything -out $MYDOMAIN.signed.pem -infiles $MYDOMAIN.pem

– убираем из приват ключа пароль
openssl rsa -in $MYDOMAIN.pem -out $MYDOMAIN.wo.pwd.pem

– для сайта берем MYDOMAIN-wwwkeyunsecure.pem
– и не забыть РАЗНЫЕ СЕРТИФИКАТЫ вешать на РАЗЫНЕ ИП адреса !

24 August 2007, 19:12:57

ca.crt – это сертификат “—–BEGIN CERTIFICATE—–”
ca.key – это ПРИВАТНЫЙ КЛЮЧ “—–BEGIN RSA PRIVATE KEY—–”

1) нам надо создать сертификат
2) подписать его нашим CA сертификатом

СОЗДАНИЕ CA ROOT CERTIFICATE

Создание сертификата :
(1)
http://tldp.org/HOWTO/SSL-Certificates-HOWTO/x195.html
creates a new private key and a certificate request and place it as newreq.pem.
Enter a Common Name (CN) the main usage of the certificate for instance www.sopac.org if you want to secure the website www.sopac.org,
or enter franck@sopac.org if you want to use to secure the e-mails of franck@sopac.org

openssl req -config /etc/ca.config -new -keyout newreq.pem -out newreq.pem -days 365

1
2
3
cd /etc/ssl/
###openssl req -config ./ca.config -new -keyout su.host-lux.ru.pem -out su.host-lux.ru.pem  -days 1825
openssl req -config ./ca.config -new -keyout su.host-lux.ru-newreq.pem -out su.host-lux.ru-newreq.pem  -days 1825

Подписываем сертификат нашим СА

openssl ca -config /etc/ca.config -policy policy_anything -out newcert.pem -infiles newreq.pem

1
2
openssl ca -config ./ca.config -policy policy_anything -out su.host-lux.ru-cert.pem  -infiles su.host-lux.ru.pem
openssl ca -config ./ca.config -policy policy_anything -out su.host-lux.ru-newcert.pem  -infiles su.host-lux.ru-newreq.pem

will sign the request using the cacert.pem and commit the certificate as newcert.pem.
You will need to enter the passphrase of the cacert.pem (your CA Certificate).
The file newcerts/xx.pem will be created and index.txt and serial will be updated

You private key is in newreq.pem -PRIVATE KEY- and your certificate is in newcert.pem -CERTIFICATE-
A copy of newcert.pem is placed in newcerts/ with an adequate entry in index.txt so that a client can request this information via a web server to ensure the authenticity of the certificate.
Beware of your newreq.pem file, because it contains a certificate request, but also your private key. The -PRIVATE KEY- section is not required when you sign it. So if you request someone else to sign your certificate request, ensure that you have removed the -PRIVATE KEY- section from the file. If
you sign someone else 1
certificate request, request from this person its -CERTIFICATE REQUEST- section not its private key.

3.1.1. Using a certificate with mod_ssl in apache
First never use your self-signed root CA Certificate with any application and especially with apache as it requires you to remove the passphrase on your private key.
First generate and sign a certificate request with the Common Name (CN) as www.mysite.com. Remove any extra information to keep only the —CERTIFCATE — part.
The key needs to be made insecure, so no password is required when reading the private key. Take the newreq.pem files that contains your private key and remove the passphrase from it.
openssl rsa -in newreq.pem -out wwwkeyunsecure.pem

# openssl rsa -in newreq.pem -out wwwkeyunsecure.pem
# openssl rsa -in su.host-lux.ru.pem -out su.host-lux.ru-wwwkeyunsecure.pem

# openssl rsa -in su.host-lux.ru-newreq.pem -out su.host-lux.ru-wwwkeyunsecure.pem

2.5.4. Display a certificate
You may have a certificate in its coded form, to read the details of the certificate just issue the following command:
openssl x509 -in newcert.pem -noout -text

How to get short access to class in Java ?

For example we have such class with static methods :

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
    private static final String IMAGE_FOLDER = "images/";
    public static final String IMAGE1 = "image1";
    public static final String IMAGE2 = "image2";
    public static final String IMAGE3 = "image3";

    public static final int BARCODE_DATA_TYPE_VOUCHER_ID = 0;
    public static final int BARCODE_DATA_TYPE_JOURNAL_ID = 1;
    public static final int BARCODE_DATA_TYPE_RECEIPT_BARCODE = 2;

    /** Here is an array of month in Russian in proper case for displaying in DD MMMM YYYY format */
    private static final String[] RUSSIAN_MONTH = {"января", "февраля", "марта", "апреля", "мая", "июня",
            "июля", "августа", "сентября", "октября", "ноября", "декабря"};

    private static DateFormatSymbols russSymbol = new DateFormatSymbols();
    static {
        russSymbol.setMonths(RUSSIAN_MONTH);
    }

    private static final SimpleDateFormat dateFormater = new SimpleDateFormat("dd MMMM yyyy", russSymbol);

    /** Map of cyrillic symbols from cp1251 to */
    private static Map<Character, String> cyrillicCp1251ToUNICODE = new HashMap<Character, String>();
    static {
        cyrillicCp1251ToUNICODE.put('а', "\u0430");
        cyrillicCp1251ToUNICODE.put('А', "\u0410");
        cyrillicCp1251ToUNICODE.put('б', "\u0431");
        cyrillicCp1251ToUNICODE.put('Б', "\u0411");
        cyrillicCp1251ToUNICODE.put('в', "\u0432");
        cyrillicCp1251ToUNICODE.put('В', "\u0412");
        cyrillicCp1251ToUNICODE.put('г', "\u0433");
        cyrillicCp1251ToUNICODE.put('Г', "\u0413");
        cyrillicCp1251ToUNICODE.put('д', "\u0434");
        cyrillicCp1251ToUNICODE.put('Д', "\u0414");
        cyrillicCp1251ToUNICODE.put('е', "\u0435");
        cyrillicCp1251ToUNICODE.put('Е', "\u0415");
        cyrillicCp1251ToUNICODE.put('ё', "\u0451");
        cyrillicCp1251ToUNICODE.put('Ё', "\u0401");
        cyrillicCp1251ToUNICODE.put('ж', "\u0436");
        cyrillicCp1251ToUNICODE.put('Ж', "\u0416");
        cyrillicCp1251ToUNICODE.put('з', "\u0437");
        cyrillicCp1251ToUNICODE.put('З', "\u0417");
        cyrillicCp1251ToUNICODE.put('и', "\u0439");
        cyrillicCp1251ToUNICODE.put('И', "\u0418");
        cyrillicCp1251ToUNICODE.put('й', "\u0439");
        cyrillicCp1251ToUNICODE.put('Й', "\u0419");
        cyrillicCp1251ToUNICODE.put('к', "\u043a");
        cyrillicCp1251ToUNICODE.put('К', "\u041a");
        cyrillicCp1251ToUNICODE.put('л', "\u043b");
        cyrillicCp1251ToUNICODE.put('Л', "\u041b");
        cyrillicCp1251ToUNICODE.put('м', "\u043c");
        cyrillicCp1251ToUNICODE.put('М', "\u041c");
        cyrillicCp1251ToUNICODE.put('н', "\u043d");
        cyrillicCp1251ToUNICODE.put('Н', "\u041d");
        cyrillicCp1251ToUNICODE.put('о', "\u043e");
        cyrillicCp1251ToUNICODE.put('О', "\u041e");
        cyrillicCp1251ToUNICODE.put('п', "\u043f");
        cyrillicCp1251ToUNICODE.put('П', "\u041f");
        cyrillicCp1251ToUNICODE.put('р', "\u0440");
        cyrillicCp1251ToUNICODE.put('Р', "\u0420");
        cyrillicCp1251ToUNICODE.put('с', "\u0441");
        cyrillicCp1251ToUNICODE.put('С', "\u0421");
        cyrillicCp1251ToUNICODE.put('т', "\u0442");
        cyrillicCp1251ToUNICODE.put('Т', "\u0422");
        cyrillicCp1251ToUNICODE.put('у', "\u0443");
        cyrillicCp1251ToUNICODE.put('У', "\u0423");
        cyrillicCp1251ToUNICODE.put('ф', "\u0444");
        cyrillicCp1251ToUNICODE.put('Ф', "\u0424");
        cyrillicCp1251ToUNICODE.put('х', "\u0445");
        cyrillicCp1251ToUNICODE.put('Х', "\u0425");
        cyrillicCp1251ToUNICODE.put('ц', "\u0446");
        cyrillicCp1251ToUNICODE.put('Ц', "\u0426");
        cyrillicCp1251ToUNICODE.put('ч', "\u0447");
        cyrillicCp1251ToUNICODE.put('Ч', "\u0427");
        cyrillicCp1251ToUNICODE.put('ш', "\u0448");
        cyrillicCp1251ToUNICODE.put('Ш', "\u0428");
        cyrillicCp1251ToUNICODE.put('щ', "\u0449");
        cyrillicCp1251ToUNICODE.put('Щ', "\u0429");
        cyrillicCp1251ToUNICODE.put('ъ', "\u044a");
        cyrillicCp1251ToUNICODE.put('Ъ', "\u042a");
        cyrillicCp1251ToUNICODE.put('ы', "\u044b");
        cyrillicCp1251ToUNICODE.put('Ы', "\u042b");
        cyrillicCp1251ToUNICODE.put('ь', "\u044c");
        cyrillicCp1251ToUNICODE.put('Ь', "\u042c");
        cyrillicCp1251ToUNICODE.put('э', "\u044d");
        cyrillicCp1251ToUNICODE.put('Э', "\u042d");
        cyrillicCp1251ToUNICODE.put('ю', "\u044e");
        cyrillicCp1251ToUNICODE.put('Ю', "\u042e");
        cyrillicCp1251ToUNICODE.put('я', "\u044f");
        cyrillicCp1251ToUNICODE.put('Я', "\u042f");
    }

    private static final ILogger LOGGER = *Factory.getLogger();
....
}

Add this :

1
2
3
4
5
6
7
public class ReportUtilities {
....
}
    // InnerClass to access the ReportUtilities only by typing Utils
    public static class Utils extends ReportUtilities {
        // empty class stub
    }

Samepl DigitNumberFormat

Sample of Digit formating :

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
/**
 * Copyright 2012 <br>
 */

package info.abnsoft.java.tryheap;

import java.math.BigDecimal;
import java.text.DecimalFormat;
import java.text.DecimalFormatSymbols;

/**
 * @author annik
 *
 */

public class DecimalFormatTest {

    /** This method
     * @param args
     */

    public static void main(String[] args) {
        double[] n = { 1, 12.0, 123.9, 123.456, 123E5, 123E-5 };

//        // 0 represents 1 digit
//        DecimalFormat f = new DecimalFormat("00.00");
//        System.out.println("Formatting with 0.00");
//        for (int i = 0; i < n.length; i++) {
//            System.out.println(n[i] + ": " + f.format(n[i]));
//        }
//
//        // # is one digit, but can be omitted if it is 0
//        f = new DecimalFormat("#0.0#");
//        System.out.println("\nFormatting with #0.0#");
//        for (int i = 0; i < n.length; i++) {
//            System.out.println(n[i] + ": " + f.format(n[i]));
//        }
//
//        // prefixes and suffixes can be added
//        // befause # is special character, it is enclosed between ' s
//        f = new DecimalFormat("$#0.0# m/s'#'");
//        System.out.println("\nFormatting with $#0.0 m/s'#'");
//        for (int i = 0; i < n.length; i++) {
//            System.out.println(n[i] + ": " + f.format(n[i]));
//        }
//
//        // grouping separators can be added
//        f = new DecimalFormat("$#,##0.00");
//        System.out.println("\nFormatting with $#,##0.00");
//        for (int i = 0; i < n.length; i++) {
//            System.out.println(n[i] + ": " + f.format(n[i]));
//        }

        // String.format
        System.out.println("====================");
//        System.out.println( String.format("%,.2f", new BigDecimal(20123.12)));

        // String.format
        DecimalFormatSymbols df = DecimalFormatSymbols.getInstance();
        df.setGroupingSeparator(',');
        df.setDecimalSeparator('.');
        df.setDigit('D');

        DecimalFormat formatter = new DecimalFormat();
        formatter.setDecimalFormatSymbols(df);
        formatter.setMaximumFractionDigits(2);

        System.out.println(formatter.format(new BigDecimal(20123.12345678)));

    }
}

Real code is :

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
    /**
     * Return the formatted BigDecimal digit or an empty string if the number is null. This method useful when
     * we should get abs() value, which is BigDecimal.
     *
     * @param bigDecimal
     * @param groupingSeparator
     * @param decimalSeparator
     * @param maximumFractionDigits
     * @return
     */

    public static String toDisplayFormat(final BigDecimal bigDecimal, final char groupingSeparator,
            final char decimalSeparator, final int maximumFractionDigits) {

        DecimalFormatSymbols df = DecimalFormatSymbols.getInstance();
        df.setGroupingSeparator(groupingSeparator);
        df.setDecimalSeparator(decimalSeparator);

        DecimalFormat formatter = new DecimalFormat();
        formatter.setDecimalFormatSymbols(df);
        formatter.setMaximumFractionDigits(maximumFractionDigits);
        formatter.setMinimumFractionDigits(maximumFractionDigits);

        if (bigDecimal != null) {
            return formatter.format(bigDecimal);
        }
        return "";
    }

How to GENERATE GOOGLE MAPS API KEY for android ?

Thanks Damarias : http://www.youtube.com/watch?v=XdduYAs7klY

You have keytoll.exe in your JAVA_HOME/bin. CD to there and run :
we will use info from that page : https://developers.google.com/maps/documentation/android/v1/mapkey?hl=es-ES#getfingerprint

1
2
3
$ keytool -list -alias androiddebugkey \
-keystore <path_to_debug_keystore>.keystore \
-storepass android -keypass android

then open eclipse : window > Preference [ Android > Build : ~ enter your Custom debug key there ]

open page for sign-up your MD5 FINGER PRINT : https://developers.google.com/maps/documentation/android/v1/maps-api-signup?hl=es-ES

enter there you MD5 string.

then copy API-KEY and insert that in android project

SPRING SETTINGS

SPRING setings

SPRING setings

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
  <modelVersion>4.0.0</modelVersion>
  <groupId>WebServiceValute</groupId>
  <artifactId>WebServiceValute</artifactId>
  <version>0.0.1-SNAPSHOT</version>
  <packaging>war</packaging>
  <dependencies>
    <dependency>
      <groupId>javax.activation</groupId>
      <artifactId>activation</artifactId>
      <version>1.1.1</version>
    </dependency>
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-context</artifactId>
        <version>3.2.0.RELEASE</version>
    </dependency>
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-aspects</artifactId>
        <version>3.2.0.RELEASE</version>
    </dependency>
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-orm</artifactId>
        <version>3.2.0.RELEASE</version>
    </dependency>
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-oxm</artifactId>
        <version>3.2.0.RELEASE</version>
    </dependency>
    <dependency>
        <groupId>axis</groupId>
        <artifactId>axis</artifactId>
        <version>1.4</version>
    </dependency>
    <dependency>
        <groupId>javax</groupId>
        <artifactId>javaee-api</artifactId>
        <version>6.0</version>
    </dependency>
  </dependencies>
  <build>
    <plugins>
      <plugin>
        <artifactId>maven-compiler-plugin</artifactId>
        <version>2.3.2</version>
        <configuration>
          <source>1.6</source>
          <target>1.6</target>
        </configuration>
      </plugin>
      <plugin>
        <artifactId>maven-war-plugin</artifactId>
        <version>2.2</version>
        <configuration>
          <warSourceDirectory>WebContent</warSourceDirectory>
          <failOnMissingWebXml>false</failOnMissingWebXml>
        </configuration>
      </plugin>
    </plugins>
  </build>
</project>

SPRING annotation config

4.9 Annotation-based container configuration

1
2
3
4
5
6
7
8
9
10
11
12
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:context="http://www.springframework.org/schema/context"
    xsi:schemaLocation="http://www.springframework.org/schema/beans
        http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
        http://www.springframework.org/schema/context
        http://www.springframework.org/schema/context/spring-context-3.0.xsd">


   <context:annotation-config/>

</beans>