Archive for April, 2008

Web design course - Chapter 17 . ODBC/JDBC 515 the getConnectionmethod. GetConnectiontakes

Wednesday, April 30th, 2008

Chapter 17 . ODBC/JDBC 515 the getConnectionmethod. GetConnectiontakes a string URL as an argument. In the case of MySQL, you provide the URL and credentials for the connection: Connection con; con = DriverManager.getConnection(url, username , password ); Alternatively: Connection con = DriverManager.getConnection(url, username , password ); The basics of handling statements and results The Statementinterface with the JDBC is not an object, but rather, an interface for creating an object that executes statements. You create a Statementobject as follows: Statement stmt = connection.CreateStatement(); With the Statement object created, you use an execute method on the object. There are four execute methods for use with the JDBC: executeQuery(), executeUpdate(), executeBatch(), and execute(). The executeQuery()method is for statements such as SELECT that retrieve values from a database. The executeUpdate() method is used commonly with DDL statements that don t return values but may return a number of rows affected by the operation. Finally, the execute()method is for statements that return greater than one result or count. The executeUpdate() method returns an integer value that contains the number of rows affected by the operation. The results from queries are retrieved using ResultSet. For example: ResultSet result = statement.executeQuery( SELECT * FROM user ); To access the results, use a get method. The basic methods for accessing data are as follows: getBoolean() getByte() getDate() getDouble() getFloat() getInt() getLong() getShort() getString() getTime() getTimestamp()
From our experience, we can recommend PHP Web Hosting services, if you need affordable webhost to host and run your web application.

514 Part IV . Development Figure 17-32: The (Web hosting mysql)

Tuesday, April 29th, 2008

514 Part IV . Development Figure 17-32: The error message given when the CLASSPATH variable hasn t been set For more information on installing and using the Java Software Development Kit, see the Sun Web site, http://java.sun.com. Using the JDBC and the MySQL Driver The JDBC itself defines the methods by which you connect to a database. This section looks at how to create a connection to a MySQL database and issue statements with the JDBC. Before doing so, I d like to go over some basic terminology and concepts. The concepts and terms of JDBC The first step involved in making the JDBC work with a database is loading a driver. The JDBC java.sql.DriverManagerclass performs this task. The DriverManager class also works with the Driver so you don t need to. The forName() method loads the Driver class. Note Although you can also load the Driver class by using jdbc.drivers, I recommend using the forName() method for the sake of consistency. The Class.forname() method takes a string as an argument. In the case of the MySQL JDBC driver, this string is: org.gjt.mm.mysql.Driver For example: Class.forName( org.gjt.mm.mysql.Driver ); The getConnectionmethod is called to make the actual connection to the database server. The DriverManager creates a Connection object when you call
You want to have a cheap webhost for your apache application, then check apache web hosting services.

Web site development - Chapter 17 . ODBC/JDBC 513 Figure 17-31: The

Monday, April 28th, 2008

Chapter 17 . ODBC/JDBC 513 Figure 17-31: The Java JDK installer requires no compilation to install the software. Running this command yields a directory called mm-2.0.9 in /usr/local/jdk1.3.1_02. Inside of the mm-2.0.9 directory there is a file called mm.mysql-2.0.9-bin.jar. Copying that file to /usr/local/jdk1.3.1_02/jre/lib/ext copies the class files for the MySQL JDBC API. If your installation is in a different location, copy the file to /jre/lib/ext/. Note Version numbers of both the Java JDK and the MySQL JDBC driver will probably change by the time you read this. For my installation, I also added the JDK s binary directory to my path. In addition, you may want to add the MySQL JDBC driver location to your CLASSPATH. Using csh or tcsh, the command that does so looks like this: setenv CLASSPATH /path/to/mysql-jdbc-class:.:$CLASSPATH Should you receive an error such as that shown in Figure 17-32, then no CLASSPATH is defined at all. In this instance, I recommend setting it to include the JDK directory as well, using the following command line: setenv CLASSPATH /path/to/jdk:/path/to/mysql-jdbc-class:
Searching for affordable and reliable webhost to host and run your web applications? Go to our java web server services and you will be pleased.

512 Part IV . Development Execute the file

Sunday, April 27th, 2008

512 Part IV . Development Execute the file as you would any other program located in a directory not in your path, as follows: ./j2sdk-.bin Again, be sure to run the JDK installer binary from the location where you want it installed. If you want the JDK in /usr/local/j2sdk-We recommend cheap and reliable webhost to host and run your web applications: Coldfusion Web Hosting services.

Bulletproof web design - Chapter 17 . ODBC/JDBC 511 The JDBC interface

Saturday, April 26th, 2008

Chapter 17 . ODBC/JDBC 511 The JDBC interface JDBC for MySQL is a slight misnomer; Java database connectivity is, in fact, available for various RDBMS programs. In effect, JDBC functions like the Perl DBI it enables a range of database drivers to connect to various RDBMS products. For the purposes of this book, when I refer to the JDBC interface, I refer to a particular API the MySQL driver that works with the JDBC. The JDBC API itself is included with the core Java Software Development Kit (abbreviated as SDK or JDK I use JDK throughout this chapter). In particular, the java.sql package contains the classes needed for using MySQL to work with data. Where to get the JDBC and MySQL JDBC Driver The MySQL JDBC API is not an official MySQL AB product. However, the MySQL JDBC driver is linked from the MySQL AB Web site. I found the versions of the MySQL JDBC driver linked directly from MySQL AB s Web site to be relatively old. A newer version of the MySQL JDBC driver can usually be obtained directly from the following Web site: http://mmmysql.sourceforge.net/. The file format for the MySQL JDBC driver is a Java archive; you need the jar program to unpack it. You can obtain jarat the following Web site: http://mmmysql.sourceforge.net/ Getting the driver shouldn t be a problem; the Java Software Development Kit (JDK) is another a prerequisite to installing the JDBC MySQL driver. If you don t have the JDK, download it from the following Web site: http://java.sun.com/products/ Although I m hesitant to offer this link as the definitive Sun Java Web site (its location may change in the future), that s where you can download the latest JDK for Linux. Installing the MySQL JDBC Driver Before installing the MySQL JDBC driver, make sure you have the Java JDK installed. The JDK comes in a binary format, with a file extension of .bin. When you run the binary program, it creates a directory (below your current directory) and installs the Java JDK automatically. After you download the Java JDK, you may have to change the mode of the file before you can execute it. The command for doing so is as follows: chmod 700 j2sdk-.bin
Note: If you are looking for cheap and reliable webhost to host and run your mysql application check mysql web server services.

510 Part IV . Development Figure 17-29: The (Web hosting ecommerce)

Friday, April 25th, 2008

510 Part IV . Development Figure 17-29: The data from MySQL imported through Microsoft Query Tip Should you encounter problems with the import process, check to make sure that your ODBC connection is working properly. The quickest fix is to get MySQL and Microsoft Access talking to each other. Try to connect with ODBC in Microsoft Access. If this works, then you may have a problem other than the import process itself (for example, an incompatibility in driver versions). An Introduction to JDBC Java Database Connectivity (JDBC) is the Java version of the interface used for connection to more than one relational database management system (RDBMS). A JDBC API exists for MySQL, in several versions. Presently only one version is available under the Lesser GNU Public License (LGPL). Using the JDBC for MySQL, you can connect Java programs and applets to a MySQL database. This section examines the installation of the MySQL JDBC in Linux as well as how to connect to MySQL in a Java program.
In case you need quality webspace to host and run your web applications, try our personal web hosting services.

Chapter 17 . (Web design portfolio) ODBC/JDBC 509 Figure 17-26: The

Thursday, April 24th, 2008

Chapter 17 . ODBC/JDBC 509 Figure 17-26: The Finish dialog box for the Query Wizard Figure 17-27: Choosing a location to which to save the query for later retrieval Figure 17-28: The Database dialog box in Microsoft Word after successful completion of the Microsoft Query Wizard 14. Click Insert Data. The data appears in your Word document, as illustrated in Figure 17-29. Congratulations! You ve imported the data into a Word document.
We recommend high quality webhost to host and run your jsp application: christian web host services.

508 Part IV . Development The Sort Order

Wednesday, April 23rd, 2008

508 Part IV . Development The Sort Order dialog box appears, as shown in Figure 17-25. If you want to sort your results, you can do so by selecting the appropriate columns and choosing a sort order. 11. When you ve completed the Sort Order dialog box (or decided not to use it), click Next. A Finish box appears, as in Figure 17-26. 12. If you decide not to save the query (for example, when you follow the steps in this book purely for practice), you won t be able to retrieve the results later without rebuilding the query. To save your query for later retrieval, click the Save Query button, which starts the saving procedure by giving you a choice of locations for the saved query (see Figure 17-27). 13. Once you complete the Query Wizard, if you elect to send the data back to Microsoft Word, the Database dialog box appears again in Word, as illustrated in Figure 17-28. Figure 17-24: The Filter Data dialog box, as seen in the Query Wizard Figure 17-25: Sorting results by using the Sort Order dialog box
We recommend high quality webhost to host and run your jsp application: christian web host services.

Chapter 17 . ODBC/JDBC 507 Figure 17-22: Query (Free php web host)

Wednesday, April 23rd, 2008

Chapter 17 . ODBC/JDBC 507 Figure 17-22: Query Wizard - Choose Columns opens with the tables from the database (as defined in the ODBC connection you chose). 9. Click Next to continue, which brings up a Filter Data dialog box (as shown in Figure 17-24). 10. The Filter Data dialog box assists you in determining if you want to select only certain records or rows. If you do not want to filter your data, click Next. Figure 17-23: Selecting columns for a query in the Query Wizard
Please visit Domain Name Hosting services for high quality webhost to host and run your jsp applications.

506 Part IV . (Kids web site) Development Figure 17-21: Microsoft

Tuesday, April 22nd, 2008

506 Part IV . Development Figure 17-21: Microsoft Query opens with the Choose Data Source box. If Microsoft Query is not installed, then (depending on the options you have enabled) you are prompted to install it. If you agree to install Query, a wizard guides you through the process. Follow the on-screen steps it presents, and then resume importing your data into Word, starting with Step 6 here (which uses the Query Wizard to complete the data transfer). 6. Select the MySQL ODBC connection that you d like to begin working with and click OK (in this example, it s called sample-MySQL). The Query Wizard - Choose Columns dialog box opens; you should see all tables listed in the database configured in the ODBC connection, as in Figure 17-22. 7. From within the Choose Columns portion of the Query Wizard, choose the columns you want to include in the query. If there s a plus sign next the table name you can click it to expand the columns within the table. 8. Highlight a column name and then click the right arrow to move it into the Columns in your Query area, as illustrated in Figure 17-23 (where I select three columns for a query).
Looking for affordable and reliable webhost to host and run your business application? Then look no more and go to servlet web hosting services.