Thursday, July 28, 2011

Adding JAXB / jxc support in maven

Put your schemas (*.xsd) and bindings (*.xjb) into the src/main/resources folder.
Correct pom.xml as you add:
       <arg>-nv</arg><!-- this disable strict schema validation -->

First steps in maven - empty project

First way - iteractive
Go to the directory, where you want to place the folder of the new project (d:\projects)
mvn archetype:generate
Some output from maven show. We run the interaction version. Here are my answers to it:
Choose a number: 112:
Choose version:
1: 1.0-alpha-1
2: 1.0-alpha-2
3: 1.0-alpha-3
4: 1.0-alpha-4
5: 1.0
6: 1.1
Choose a number: 6: 5
Define value for property 'groupId': : com.YOUR_COMPANY.YOUR_PROJECT_PACKAGE
Define value for property 'artifactId': : PROJECT_NAME
Define value for property 'version':  1.0-SNAPSHOT: : PROJECT_VERSION
Define value for property 'package':  com.YOUR_COMPANY.YOUR_PROJECT_PACKAGE: :
Confirm properties configuration:
artifactId: PROJECT_NAME
package: com.sepbulgaria.eshop.messages
You are ready!

Second way - non-interactive

mvn archetype:generate -DartifactId=my-app -Dversion=1.0-SNAPSHOT -DinteractiveMode=false

Wednesday, July 27, 2011

Extending enums in Java

public enum DataStatus

    private String code;
    private DataStatus(String code) {
         this.code = code;
    public String getCode() { return code; }
    public String toString(){ return code; } // if you want it so
    public static DataStatus parse( String s ){
        s = s.toUpperCase();
        if( s.equals( "SUCCESSFUL" ) )
            return SUCCESSFUL;
        if( s.equals( "DECLINED-BY-USER" ) )
            return DECLINED_BY_USER;
        if( s.equals( "SPAM" ) )
            return SPAM;
        return null;

Monday, July 18, 2011

kickstart commands for mysql (create database & user)

mysql -u root -p --port=3306

CREATE DATABASE database_name;

CREATE USER 'user1'@'localhost' IDENTIFIED BY 'pass1';

GRANT SELECT,INSERT,UPDATE,DELETE,DROP,CREATE       ON database_name.* TO 'user1'@'localhost';


(mysql database) UPDATE user SET Password=PASSWORD('new_pass') WHERE User='username';

(mysql database) UPDATE user SET User='username_new' WHERE User='username_old';

For everyone host use '%' instead of 'localhost'

Wednesday, July 13, 2011

svn.exe for Windows

The problem is that tortoise svn comes without svn.exe, no command utility exists... Bad for all black screen fans.

The solution is to download from here, or newer version, if available. Point PATH variable to bin folder and you are done. All needed DLL are inside the archive.