Showing posts with label java. Show all posts
Showing posts with label java. Show all posts

Monday, May 17, 2010

Perfect java IDE for beginners

We have many java IDEs. Netbeans, Eclipse, IntelliJ being the most popular.

I'm an ardent netbeans follower. But there was a pressing problem in my mind about IDEs. What is the best IDE for a beginner; for a person who learns java?

The problem with Netbeans, Eclipse and IntelliJ is that they are meant for adavanced programmers. They are production tools and not learning tools.
  1. They have cool yet 'not good for beginner' features like code completion
  2. They have a rather complicated 'project structure' for the code. In other words they are not meant to write small 1 page, 1 file programs.
  3. They are huge programs

Other option for the beginner is to program using a text editor, compile via command line. This is good but the beginner need to learn more 'techy' stufff like command line args, vim etc. This is very troublesome for the teacher.

So what we need a bare bone level IDE which
  1. Does not have code completion and support
  2. Facilitates writing short 1 page, 1 file programs without a complicated project structure.
  3. Can compile the code with a single click
  4. Should be smaller in size

Recently I came across 'Jcreator LE' which is free and crippled version. Yep that is crippled by removing features like code completion and that makes it the ideal IDE for learners.

Thursday, July 30, 2009

Sample code for accessing mySQL from java

import java.sql.*;


public class DBConnect {

/**
* @param args
*/
public static void main(String[] args) {

Connection connection = null;

try {
String driverName = "com.mysql.jdbc.Driver"; // MySQL MM JDBC driver
Class.forName(driverName);
connection = DriverManager.getConnection("jdbc:mysql://localhost:3306/databaseName", "userName", "password");
}
catch (Exception e) {
e.printStackTrace();
}

Statement stmt;
String s;
String own;

try {
stmt = connection.createStatement();
ResultSet rs = stmt.executeQuery("SELECT * FROM pet");
while (rs.next()) {
// Get the data from the row using the column name
s = rs.getString("name");
own = rs.getString("owner");
System.out.println(s + " owned by " + own);
}
}
catch (SQLException e) {
e.printStackTrace();
}
}

}