Sunday, October 31

Mysql: merubah NULL pada hasil select statemen di mysql

Bagaimana cara mengatasi return value berupa NULL, pada saat mengambil data di mysql dengan statemen select? Berdasarkan pengalaman jika pakai bahasa java dan mengambil data dari database dan nilai yang didapatkan NULL maka akan terjadi NullPointerException Error.
caranya adalah sebagai berikut:

SELECT COALESCE(Max(id),0) AS MaxId
FROM `test`


Maksud dari script diatas adalah mengambil nilai maksimum dari id dan hasilnya NULL maka diganti nilai NULL tersebut diganti dengan 0.

Sunday, October 24

Java: Arabict text encoding in Java and Mysql

I do not have a problem when retrieving arabic text data from mysql database. But when the input Arabic text into my database is having problems. Arabic text changed to "????", so it can not be read. after looking for a solution, I found a way to solve it.
First, the Arabic text should be encoded first by using the code:
StrToEncode String = "بسم الله";
String encoded = URLEncoder.encode (strToEncode, "UTF-8");

now, that has been encoded strToEncode changed to:
% D8% A8% D8% B3% D9% 85 +% D8% A7% D9% 84% D9% 84% D9% 87

encode the string that is inserted into the mysql. then to read the Arabic text data from mysql database needs to be decoded using the code:

String correctDecoded = URLDecoder.decode (encoded, "UTF-8");

and the results of correctDecode:
بسم الله

Java: How to Install GWT in Netbeans

Google Web Toolkit (GWT) is an open source web development framework that allows developers to easily create high-performance AJAX applications using Java. Google Web Toolkit is getting a lot of attention in the web developer community thanks to its interesting way of avoiding the need to write JavaScript code for interactive web applications. You can download this GWT plug-in here and start developing GWT-based applications in NetBeans.

With GWT, you are able to write your front end in Java, and it compiles your source code into highly optimized, browser-compliant JavaScript and HTML. "Writing web apps today is a tedious and error-prone process. You spend 90% of your time working around browser quirks, and JavaScript's lack of modularity makes sharing, testing, and reusing AJAX components difficult and fragile. It doesn't have to be that way," reads the Google Web Toolkit site.

In this tutorial, you learn how the above principles are applied to real applications. At the same time, you are introduced to NetBeans IDE's support for GWT and you build a simple application that makes use of some of these features.
1. Download GWT plugin here
2. Install the plug-in using the Plug-in manager. Go to the "Tools | Plugins" menu action, switch to the "Downloaded" tab and locate the plug-in on your disk drive.
You don't even have to restart your IDE - GWT support is instantly available for you!

Creating the Source Structure of a GWT Application
1. Choose File > New Project (Ctrl-Shift-N). Under Categories, select Web (or Java Web). Under Projects, select Web Application. Click Next.
2. In step 2, Name and Location, type HelloGWT in Project Name. You can also specify the location of the project by typing in a path on your computer in Project Location field. Click Next.
3. In the Server and Settings step, select any server that you have registered in the IDE. If you included Tomcat or the GlassFish server when installing the IDE, they display in the drop-down list.
4. Specify the Java version you are using. Click Next.
5. In the framework Step, select GWT:

6. click finish.
7. In the Projects window, right-click the project node and choose Run. The application is built and a web archive (WAR) is created. It is deployed to the server. The server starts, if it is not running already. Your computer's default browser opens and the welcome page of the application is displayed.

source : http://netbeans.org/kb/docs/web/quickstart-webapps-gwt.html

Java: Split String dan Membuang Token yang Sama

Kembali ke java... Pada tutorial ini saya akan membahas tentang cara untuk men-split sebuah string menjadi token-token yang dipisahkan oleh beberapa delimiter dan membuang token-token yang sama. Jadi hasilnya adalah token-token yang bersifat unik.
for example:
String input = "AAAA AAAA BBBB BBBB CCCC djgu";

the result should be: {AAAA, BBBB, digu, CCCC}

Nah source code yang saya gunakan adalah sebagai berikut:

String s2 = "cahdt aaaa aaaa bbbbb ddddd";

List li = new ArrayList ();
StringTokenizer st = new StringTokenizer (s2 ,";&@! - ");

while (st.hasMoreTokens ()) {
String temp = st.nextToken ();
li.add (temp);
}

Set set2 = new HashSet (li);
String [] result2 = new String [set2.size ()];
set2.toArray (result2);
for (String s: result2) {
System.out.print (s + ",");
}

Friday, October 22

Hosting gratis di Ziddu

Ziddu itu apa sih? Ziddu adalah penyedia hosting gratis. Ya, kita dapat mengupload file-file dari komputer kita dan kita bisa share dengan teman-teman (yang membutuhkan... :-)). Yang lebih asyik dari ziddu ini adalah kita bisa mendapatkan komisi jika file-file yang kita upload di download oleh pengguna internet di seluruh dunia. Berapa komisi yang kita dapatkan untuk satu kali unique download? 0.001 dollar. kalo di rupiahkan ya sekitar 10 rupiah untuk setiap download. Ini akan mengasyikkan jika banyak pengguna internet yang mengakses web kita kemudian mendownload file-file kita. Tinggal dikalikan saja. Misalnya kita punya 100 file dan rata-rata downloadnya untuk masing-masing file adalah 100. Dapat anda hitung sendiri berapa penghasilan tambahan anda dari ziddu. Kita bisa berbagi ilmu dan kita juga bisa mendapatkan penghasilan. :-)

Dan Cukup mudah untuk menggunakan layanan di ziddu.com. Cukup daftar disini kemudian upload file-file anda. Oia... ketinggalan, ziddu juga menyediakan 0,1 dollar setiap ada satu refferal aktif yang mendaftar melalui link refferal kita. Refferal aktif adalah yang sudah upload file walaupun hanya satu file saja. Nah lumayan bukan ?

Dan berbagilah.... :-) Insya Allah bermanfaat...
[Ingat, yang di upload jangan file-file "bajakan" ya.... hehe] dosa lho....


Pencarian Google