niedenzu

Hints and tricks for developers

Martins Amazon Wunschliste

eclipse remote system explorer – shell ed – php plugin 21. October 2014

Sometimes I need to do administration stuff.
Because I am a fulltime Java Developer I feel confortable using eclipse.
I only have basic knolege about vi.
Another thing is – I work with Windows and Mac Computers – And I like software that can run on poth operating systems.

mobaxterm and WinSCP are nice Tools for SSH and sFTP but they are not eclipse.

“Remote system explorer” is a build in

shell_ed

net.sourceforge.shelled-site-2.0.1

No Comments on eclipse remote system explorer – shell ed – php plugin
Categories: Uncategorized

Trim String to fit in UTF-8 encoded DB-column 20. October 2014

Most People in the World are using more tjen the ASCIIcode. Most of our customers deal with an international audience. The only solution ist to use UTF8 everywhere. Everywhere means in the database and in the software.

UTF8 is a format to spare space.

public class WWSUtils {
	
	 public static String trimUnicodeToMaxsizeInUtf8Bytes(String input, int size) {
	        
	        //first trim - is suffucient only ASCII Usage
	        if (input.length() > size) {
	            input  = input.substring(0, size);
	        }
	        
	        while  (WWSUtils.lengthInUtf8Bytes(input) > size) {
	            input = input.substring(0, input.length() - 1);
	        }
	        
	        return input;
	    }

	     public static int lengthInUtf8Bytes(final CharSequence sequence) {
	            int count = 0;
	            for (int i = 0, len = sequence.length(); i < len; i++) {
	              final char ch = sequence.charAt(i);
	              if (ch <= 0x7F) {
	                count++;
	              } else if (ch <= 0x7FF) {
	                count += 2;
	              } else if (Character.isHighSurrogate(ch)) {
	                count += 4;
	                ++i;
	              } else {
	                count += 3;
	              }
	            }
	            return count;
	     }

}


Javascript Verison will be posted soon.

No Comments on Trim String to fit in UTF-8 encoded DB-column
Categories: Uncategorized

Postgress

which is an alternative to IBMs DB2?

I’m trying to use Postgress as a alternative DB-Server.

  • should be open source
  • shuld run on windows mac and linx
  • should be compatible with db2

I tryed postgress because, if you got to oreilly.com you get literatur and manuels.
The amount of literatur you get from oreilly.com is always a good indicator on the
attention a software or it-sytem gets.

pgsql_connection

create a Instance

The Database should use Unicode as Encoding.
Because our customer is operation world wide we need to use an Encoding which uses foreign Character sets.
You need to issue the following commant to create a UTF8 Database.

C:\Daten\pgsql\bin> initdb -D c:\Daten\pgsql-data - E UTF8

launch the databaseserver


C:\Daten\pgsql\bin>postgres -D c:\Daten\pgsql-data

PostgreSQL has the data types smallserial, serial and bigserial; these are not true types, but merely a notational convenience for creating unique identifier columns. These are similar to AUTO_INCREMENT property supported by some other databases.
If you wish a serial column to have a unique constraint or be a primary key, it must now be specified, just like any other data type.
The type name serial create integer columns. The type name bigserial create a bigint column. bigserialshould be used if you anticipate the use of more than 231 identifiers over the lifetime of the table. The type name smallserial create a smallint column.

Listing all Databases

psql -l

No Comments on Postgress
Categories: Uncategorized

Highlight code in your html-page

I made some good experience using the syntaxhighlighter_3.0.83.
It uses different Bruches to higlight different Languages such as

  • java
  • javascript
  • sql

]]>

No Comments on Highlight code in your html-page
Categories: Uncategorized

Format SQL with Java

The dynamic generated SQL of our Java-applikation needed to be formatted.
The formatted SQL was then logged in the error-log of our application.

To accomplish this task it was agood idea to use the formatter of the Hibernate Framework.
org.hibernate.engine.jdbc.internal.BasicFormatterImpl.BasicFormatterImpl()

String formattedSQL = new BasicFormatterImpl().format(sql);

In the older Version of hibernate the formatter had an older name.
I will post this name later.

No Comments on Format SQL with Java
Categories: Uncategorized
Martin Rocks