Posts Tagged ‘netbeans’

The big three: JDeveloper, Eclipse and Netbeans. Which one do you prefer?

Sunday, January 11th, 2009

I would like to get your opinion on choosing an IDE to develop Java applications.

At the moment I am using Netbeans and I am very satisfied with it. I tried to get a good comparison between them with google. There are a lot of old articles about “The big Three” but I could not get a good answer because they evolve a lot in the recent time. It is time to get an up to date situation!

Here is my opinon:

JDeveloper Pro – if you would like to migrate from oracle forms to java -> use ADF (application development framework), support all phases of software development

JDeveloper Contra – it is not independent (developed by Oracle), does not have future in open source world, slow startup

Netbeans Pro – strong community, open source, independent

Netbeans Contra – bad reputation from the past, I am missing a plug-in for data modelling

Eclipse Pro – a lot of people using it, it is fast

Eclipse Contra – I think it is losing market share, no clear vision

I would be very glad to get your opinion! Do you agree or disagree with my statements? Do not hesitate to put your comment!

Do you find this post useful? Do not hesitate to leave a reply! Go to the bottom of this page.

Would you like to use an advanced grid object instead of a classic jTable?

Thursday, September 18th, 2008

I started programming in java one year ago. I decided to convert my visual basic code to Swing. I was very unpatienced at the beginning, i did not read the swing manual, I just started to programming.

Today I will try to describe my experience with jtable and swing. In the second part I will present my grid object.

1.It is very easy to start programmic in Swing using Netbeans. It is very similar to all other RAD(Rapid application development) tools. 

2.It is very difficult to develop a more complex application in Swing on the other side. I think the basic element of every business application is a grid object. We can use jTable in Java. I was very happy, when I first saw a jTable a year ago. Ohhh, what a powerful object!!! But I got very disappointed after a few days. I realized that it is very complex to extend jTable for more serious use. And I was an absolute beginner…

3.Have anyone used PowerBuilder in the past. PB has a very powerful datagrid. I tried to develop something similar. I would like to have the following functionallity: present data in grid using SQL statement, easy editing of data…..

4.jTable is very powerful when you learn how to use rendering, cell editors, drag and drop, etc…

Ok, now it is time to move to the second part.

I have developed a grid object. It has the following features:

a) data is displayed in a grid according to sql

b) editing strarted in the next cell when user press enter or tab

c) export data to excel

d) grouping data in jtable

e) store data to database with save method

f) easy to use

Below is a picture which presents group data in a jTable.

Do you think I should start an open source project to develop this object further? Is there any other similar object with described functionalities? I am very intersting in your opinion. Please do not hesitate to answer me.

It will take me a lot of time if I would like to rewrite the object once again. At the moment it is more similar to spaghetti code. 

Ok, what is the purpose of this article? Please encourage me or give me some good arguments like :”Do not waste your time, there are thousands of similar projects….” or even better: “Do that!!! Newbies are waiting for something like this, give Swing a chance!!”

Do you find this post useful? Do not hesitate to leave a reply! Go to the bottom of this page.

Connect webservice servlet to database

Sunday, August 24th, 2008

Using database gives an application the dynamic content. Without database an application could be compared to Sahara, everything is static, sand everywhere, no waves. The goal is to bring Nile to Sahara desert.

In my previous blog http://javanus.com/blogs/?p=24 I described how to build your first web service.

Today I will try to connect a servlet to the database. I will use mysql database. What a great achivement If I will succeed?!;) I would be very happy.

1.I create a new web project in Netbeans. I add jar mysql-connector-java-5.0.7-bin.jar to the project library. You could have different mysql connector version.

2.I create a new class.

package mypackage;

import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.Statement;
import java.sql.DriverManager;
import javax.jws.WebService;
/**
 *
 * @http://www.javanus.com/blogs

 */
@WebService()
public class DatabaseExample {

    public String getName(String pUrl, Integer pId, String pUser, String pPass) {
    String ls_name = “”;
    try
     {
        //connect to database
        Class.forName(“com.mysql.jdbc.Driver”);
        Connection con = DriverManager.getConnection(pUrl, pUser, pPass);
        // query database using SQL
        Statement s = con.createStatement();
        String query = “SELECT name FROM test WHERE id = ” + pId;
        ResultSet rs = s.executeQuery(query);

        while(rs.next())
        {
           ls_name = rs.getString(“name”);
        }
        // close connection
        con.close ( );
     }
     catch (Exception e)
     {
        return “Exception ” + e.toString()+”..”+e.getMessage();
     }       
        return “Name for id ” + pId + ” is ” + ls_name + “!”;
    }
}

I build a project and deploy it to the Tomcat Web Application Server.

3.I create another project in Netbeans as Java application type.

Right click project->New->Web service client. I select WSDL radio button and put WSDL url. See the picture below.

4.In the Main Class I add a call to the webservice. See the example below.

/**
 *
 * @author http://www.javanus.com/blogs
 */
public class NewClass {
    public NewClass() {
    }
    public static void main(String[] args) {
        try { // Call Web Service Operation
            mypackage.DatabaseExampleService service = new mypackage.DatabaseExampleService();
            mypackage.DatabaseExample port = service.getDatabaseExamplePort();
            java.lang.String arg0 = “jdbc:mysql://localhost/database_name”;
            java.lang.Integer arg1 = Integer.valueOf(1);
            java.lang.String arg2 = “db_username”;
            java.lang.String arg3 = “db_password”;
            java.lang.String result = port.getName(arg0, arg1, arg2, arg3);
            System.out.println(“Result = “+result);
        } catch (Exception ex) {
        }
    }
}

5.Is the position of the stars = true? Does it work?

Yes, the position of the stars is in the harmony with my brain processes.