On Jul 8, 2004, at 3:06 PM, S. Isaac Dealey wrote:

> > If I were a betting man, I would bet that CF continues to
>  > become closer
>  > to pure Java -- this would (potentially) improve
>  > performance and
>  > broaden the acceptance/use of the CF language.
>
>  I have my doubts. The closer CF comes to pure Java, the more people
>  will ask "why bother when there's Java". In order to stay alive in the
>  market (as with any market) CF has to provide something significant to
>  the customer which they can't get elsewhere.
>

Done right, CF doesn't need to give up anything to provide optional
support for strong typing any more than they had to sacrifice anything
to give us CFCs.

Just because I can use pure Java to write an SQL query and display the
record set, with a program of 20, or so statements, doesn't
(necessarily) mean that i should abandon doing the equivalent with 2 CF
statements.  Especially since I can much more easily cache the results
and avoid db attacks with cfqueryparam -- for most apps, the CF
approach to this is much easier to implement, read/understand and
maintain. (below is a simple Java example I found that does just does a
simple equivalent of a cfquery and cfoutput.

Depending on my needs, I can write the app in Pure CF; Pure Java or a
combination of the two -- using each where it is best suited.

I like that!

Dick

// a simple query to connect to
// an Access database with an ODBC
// connection established on the local
// system
import java.sql.*;
public class SelectTest {
    // no-arg constructor
public SelectTest() { }
public void queryDatabase() {
     Connection con = null;
     ResultSet rs = null;
try {
     // connect
     Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
     con = DriverManager.getConnection("jdbc:odbc:javaforcf");
     // a simple query
     String queryString = "SELECT * FROM items;";
     Statement stmt = con.createStatement();
     rs = stmt.executeQuery(queryString);
     System.out.println("ID  ItemName   Price");
     System.out.println("__  ________   _____");
   while(rs.next()) {
     System.out.print(rs.getInt("itemID") + "  ");
     System.out.print(rs.getString("itemname") + "\t");
     System.out.print(rs.getString("itemprice"));
     System.out.println();
   }
}
catch (ClassNotFoundException cnfe) {
      System.out.println("Class not found exception thrown: Could not
locate DB driver");
}
catch (SQLException sqle) {
      System.out.println("SQL Exception: problem reported by DB" + sqle);
}
catch (Exception e) {
      System.out.println("An unknown error occurred while connecting to
DB");
}
finally {
     try {
        if (rs != null) {
           // close the result set
           rs.close();
       }
        if (con != null) {
          // close connection always
          con.close();
        }
     }
     catch (SQLException sqle) {
        System.out.println("Unable to close DB connection");
     }
   }
} /// eoq
public static void main (String args[]) {
      SelectTest st = new SelectTest();
      st.queryDatabase();
    }
}//eof
[Todays Threads] [This Message] [Subscription] [Fast Unsubscribe] [User Settings] [Donations and Support]

Reply via email to