The Artima Developer Community
Sponsored Link

Java Buzz Forum
Article Quality on Java.Net

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
Anthony Eden

Posts: 83
Nickname: aeden
Registered: Feb, 2003

Anthony Eden is President and Lead Developer of Aetrion LLC
Article Quality on Java.Net Posted: Jun 27, 2003 10:37 AM
Reply to this message Reply

This post originated from an RSS feed registered with Java Buzz by Anthony Eden.
Original Post: Article Quality on Java.Net
Feed Title: All Things
Feed URL: http://allthings.mp/
Feed Description: Blogging about Java, Python, technology and generally anything which is of interest to me.
Latest Java Buzz Posts
Latest Java Buzz Posts by Anthony Eden
Latest Posts From All Things

Advertisement

The feature story on Java Today (java.net) is called Accessing Databases from Servlets and JSP Pages. In this article is the following horrible "example" page:

<html>
<head>
<title>Accessing data in a database</title>
</head>
<body>
<%

try {
  // Step 1. Load the JDBC driver
  Class.forName("org.gjt.mm.mysql.Driver");
  
  // Step 2. Create a Connection object
  Connection con = DriverManager.getConnection(
    "jdbc:mysql///xeon/CompanySecret", 
    "budi", "secret");

  System.out.println("got connection");

  
  // Step 3. Create a Statement object and call its executeUpdate 
  // method to insert a record
  Statement s = con.createStatement();
  String sql = 
    "INSERT INTO Users VALUES ('Michael', 'Franks', '12/12/2003', 'm')";
  s.executeUpdate(sql);

  // Step 4. Use the same Statement object to obtain a ResultSet object
  sql = "SELECT FirstName, LastName FROM Users";
  ResultSet rs = s.executeQuery(sql);
  while (rs.next()) {
    out.println(rs.getString(1) + " " + rs.getString(2) + "<br>");
  }
  rs.close();
  s.close();
  con.close();
}
catch (ClassNotFoundException e1) {
  // JDBC driver class not found, print error message to the console
  System.out.println(e1.toString());
}
catch (SQLException e2) {
  // Exception when executing java.sql related commands, print error message to the console
  System.out.println(e2.toString());
}
catch (Exception e3) {
  // other unexpected exception, print error message to the console
  System.out.println(e3.toString());
}
%>
</body>
</html>

Why oh why would anyone publish an example like this today? OK, I know the answer: it is supposed to demonstrate to non-Java programmers (read VB programmers) how they can access a database from JSP. It is only an example right? But see that is where the problem is: if I am a new developer coming from another language and I see this type of coding then I will probably assume right away that this is the way JSPs should be written. Never mind the fact that all of that code could probably be reduced to one or taglib calls. Even though I don't use JSPs myself anymore I would still never demonstrate an example with this type of code. As a matter of fact why is there any reference to JSPs in the first place, why not just have the example written as a small command line application which outputs data to System.out? Heck, the title even mentions servlets although I don't see a single thing about servlets in the article.

So, after all of that, here's the point: articles which are going to be posted on java.net, a site which is sanctioned by Sun, had better be superb in all aspects, otherwise the effect of java.net will be more negative than positive.

Yes I am being hard on java.net. They have a responsibility to the developer community to produce the highest-quality content available because they can do the most damage.

Read: Article Quality on Java.Net

Topic: The Pleasures of Profiling Previous Topic   Next Topic Topic: Ideas on How to Build Reusable Aspects

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use