Please note, new blog at

ColdFusion vs. Java: Connecting to ODBC database

In my last post, I was replicating an ColdFusion array of structures in Java. This time around, I thought I would compare connecting to an Access database, executing a query, and then outputting the resultset to screen. The main thing to appreciate is how much ColdFusion does behind the scenes. You really don't have to do much, whereas in Java there is a little more to it. The tag syntax for CFML allows you to easily write complex queries, whereas this would be harder with Java. ColdFusion code <cfquery datasource="cfartgallery" name="qArtists"> SELECT * FROM artists ORDER BY lastname, firstname </cfquery> <cfoutput query="qArtists"> ID: #qArtists.artistid#<br/> Last name: #qArtists.lastname#<br/> First name: #qArtists.firstname#<br/> <br/> </cfoutput> Java code try { Class.forName("sun.jdbc.odbc.JdbcOdbcDriver").newInstance(); Connection conn = DriverManager.getConnection("jdbc:odbc:artgallery"); Statement smnt = conn.createStatement(); ResultSet res = smnt.executeQuery("SELECT * FROM artists " + "ORDER BY lastname, firstname"); while( { System.out.println("ID:" + res.getInt("artistid")); System.out.println("Last name:" + res.getString("lastname")); System.out.println("First name:" + res.getString("firstname")); System.out.println(); } conn.close(); } catch (SQLException se) { System.out.println("SQLException: " + se.getMessage()); } catch (Exception e) { System.out.println("Exception: " + e.getMessage()); }

By Anonymous Anonymous, at 4/21/2005 02:21:00 pm  

You have looked at ASP haven't you?


By Blogger Darryl Lyons, at 4/21/2005 06:59:00 pm  

Not recently. Do you mean, ASP is pretty similar, or?

Looking at an example from

set conn=Server.CreateObject("ADODB.Connection")
set rs = Server.CreateObject("ADODB.recordset")
rs.Open "Select * from Customers", conn

do until rs.EOF
for each x in rs.Fields
Response.Write(" = ")
Response.Write(x.value & "<br />")
Response.Write("<br />")


By Anonymous Anonymous, at 6/23/2006 02:41:00 am  

So easy with Coldfusion, right? Try to make a select over a table with 1 milion rows (or much less).. Good by coldfusion..


By Anonymous Anonymous, at 6/26/2006 04:16:00 am  

Why would you want to return one million rows to a client app?

That's bad programming no matter what language you're using. Most DBAs would shoot you.

By Blogger longge, at 6/25/2010 10:40:00 am  

What they acclimated for their louis vuitton handbag
are not covering or added accepted materials. There are abounding humans accustomed louis bag
with them for louis bags
of every kind.

By Blogger shoppingugg, at 7/01/2010 01:02:00 pm  

You need something to prove your true love, Tiffany jewellery of heart pendant can be the best choices. Tiffany necklaces can be the best choice. You know, silver necklaces can be a fashion and beautiful gift whether you give your love or true friends. Let them show their charm. They will be moved by you that you are so considerate. Tiffany pendants will never out of time just like your love and your friendship.

MISSION IMPOSSIBLE retailers enjoy a good margin and an increasing number of people are taking to purchasing MISSION IMPOSSIBLE DVD in bulk from a wholesaler and selling them on auction sites such as EBay and online stores. Several MISSION IMPOSSIBLE DVD COLLECTION distributors offer drop shipping and mail the DVDs directly to the end consumer on the retailer's behalf.

» Post a Comment


» Create a Link