Do you want to harness the power of PHP or Java but find it difficult to stop everything and learn these technologies?
Lots of books and training materials are available for Java and PHP, but the best education is seeing these languages as they interact with your own data. When developers decide to learn a new language, one of the first questions that occur to them is along the lines of, "How do I use Java (or PHP, or whatever) to access my own data?" There is something very meaningful and ultimately educational about seeing a new language wrapped around your own tables and columns. It helps bridge the gap between the known and the unknown in a very tangible way.
If learning Java or PHP is on your radar, then check out SQL(snap) for a quick start.
As programmers, we want to be productive immediately. I suppose there is something to be said for "Hello World" programs, but as a seasoned developer, I want to skip ahead. I want to do something productive today. I want it now! If I can learn something practical right away, I am more inclined to continue the educational process. If I have to yawn through hours of theory and obtuse examples, I usually table it for another day, which ultimately never comes.
SQL(snap) is a rapid development engine that generates Java and PHP (and RPG) based on SQL queries that you execute against your own data! This means you can immediately learn how Java and PHP are used to interact with your own tables and columns.
Let's examine a common scenario that SQL(snap) resolves easily and that provides ample education at the same time. For this example, we'll use Java. Imagine that your Web site order table is on MS SQL Server and contains customer items purchased from your online store. Now, let's say that once every hour you want to copy new orders to DB2/400 so your fulfillment function can process the orders. Let's move in a little closer and examine the steps for solving this problem.
Step 1: Build and execute a query of the Web orders table. See Figure 1.
Figure 1: Easily build a query by typing it, or build it with a few clicks.
Step 2: Now that we have determined the query we want to generate Java code for, we select "Java SQL" from the System i drop-down list and click "Generate Code." See Figure 2.
Figure 2: Select "Java SQL" to generate a Java class around this query.
Step 3: Export the Java class for use in WDSC or any IDE. See Figure 3.
Figure 3: Generated Java code is exported for use in your IDE.
Figure 3 shows the code necessary to iterate the result set created by our query from Figure 1.
Here are the steps that were automatically created by SQL(snap) from Figure 3.
A. Create a prepared statement object. Note that the values from the WHERE clause used in Figure 1 have been replaced by question marks. This is part of parameterizing the prepared statement for using different values at run time.
B. Declare the prepared statement variables based on the WHERE clause values used in Figure 1. (These can be changed at run time for greater flexibility)
C. Load the prepared statement parameters.
D. Execute the query.
E. Iterate the result set, loading the working variables with data from the actual table.
F. Clean house.
Our mission was to create a Java class that would read our Web orders table from MS SQL Server and write that data to DB2/400. Here, I have shown how easy it is to generate the Java used for the first part, which was to read the data from SQL Server. It took less than a minute to do this.
In the interest of space, the code used to update DB2/400 was not shown here. To see all the code needed for this example, visit our Web site and click on "articles."
SQL(snap) has lots of other useful features, so click over to http://www.pinchhittersoluitons.com/ and get your free 30-day trial, pricing information, and special offers. You can also download our white papers and see video tutorials for SQL(snap).
LATEST COMMENTS
MC Press Online