Archive for November, 2007

Friday, November 30th, 2007

LONGVARCHAR data can be either a variable-length String or returned by the driver as a Java InputStream, allowing the data to be read in chunks of whatever size the application desires. Exact Numeric Data: NUMERIC And DECIMAL The NUMERIC and DECIMAL data types are used to express signed, exact numeric values with a fixed number of decimal places. These data types are often used to represent currency values. NUMERIC and DECIMAL data are both represented in JDBC as Numeric objects. The Numeric class is new with JDBC, and we ll be discussing it shortly. Binary Data: BINARY, VARBINARY, And LONGVARBINARY The BINARY, VARBINARY, and LONGVARBINARY data types are used to express binary (non-character) data. These data types are represented in JDBC as Java byte arrays. Data of type BINARY is represented as a fixed-length byte array, and may include some padding zeros to ensure that it is the proper length. If data is being written to a database, the driver must ensure that the data is properly padded. Data of type VARBINARY is represented as a variable-length byte array, and is trimmed to the actual length of the data. LONGVARBINARY data can either be a variable-length byte array or returned by the driver as a Java InputStream, allowing the data to be read in chunks of whatever size the application desires. Boolean Data: BIT The BIT data type is used to represent a boolean value either true or false and is represented in JDBC as a Boolean object or boolean data type. Integer Data: TINYINT, SMALLINT, INTEGER, And BIGINT The TINYINT, SMALLINT, INTEGER, and BIGINT data types are used to represent signed integer data. Data of type TINYINT is represented in JDBC as a Java byte data type (1 byte), with a minimum value of -128 and a maximum value of 127. Data of type SMALLINT is represented in JDBC as a Java short data type (2 bytes), with a minimum value of -32,768 and a maximum value of 32,767. Data of type INTEGER is represented as a Java int data type (4 bytes), with a minimum value of -2,147,483,648 and a maximum value of 2,147,483,647. Data of type BIGINT is represented as a Java long data type (8 bytes), with a minimum value of -9,223,372,036,854,775,808 and a maximum value of 9,223,372,036,854,775,807. Floating-Point Data: REAL, FLOAT, And DOUBLE The REAL, FLOAT, and DOUBLE data types are used to represent signed, approximate values. Data of type REAL supports seven digits of mantissa precision, and is represented as a Java float data type. Data of types FLOAT and DOUBLE support 15 digits of mantissa precision, and are represented as Java double data types.
The UK has been a member of the European Union since 1973. The attitude of the present government towards further integration is conservative, with the official opposition favoring a return of some powers and competencies to the UK.From our experience, we can recommend Cheap UK Web Hosting services.

Wednesday, November 28th, 2007

// Advance to the next warning in the chain. null will be // returned if no more entries exist. chain = chain.getNextWarning(); } } JDBC Data Types The JDBC specification provides definitions for all of the SQL data types that can be supported by a JDBC driver. Only a few of these data types may be natively supported by a given database system, which is why data coercion becomes such a vital service (we ll discuss data coercion a little later in this chapter). The data types are defined in Types.class: public class Types { public final static int BIT = -7; public final static int TINYINT = -6; public final static int SMALLINT = 5; public final static int INTEGER = 4; public final static int BIGINT = -5; public final static int FLOAT = 6; public final static int REAL = 7; public final static int DOUBLE = 8; public final static int NUMERIC = 2; public final static int DECIMAL = 3; public final static int CHAR = 1; public final static int VARCHAR = 12; public final static int LONGVARCHAR = -1; public final static int DATE = 91; public final static int TIME = 92; public final static int TIMESTAMP = 93; public final static int BINARY = -2; public final static int VARBINARY = -3; public final static int LONGVARBINARY = -4; public final static int OTHER = 1111; } At a minimum, a JDBC driver must support one (if not all) of the character data types (CHAR, VARCHAR, and LONGVARCHAR). A driver may also support driver- specific data types (OTHER) which can only be accessed in a JDBC application as an Object. In other words, you can get data as some type of object and put it back into a database as that same type of object, but the application has no idea what type of data is actually contained within. Let s take a look at each of the data types more closely. Character Data: CHAR, VARCHAR, And LONGVARCHAR CHAR, VARCHAR, and LONGVARCHAR data types are used to express character data. These data types are represented in JDBC as Java String objects. Data of type CHAR is represented as a fixed-length String, and may include some padding spaces to ensure that it is the proper length. If data is being written to a database, the driver must ensure that the data is properly padded. Data of type VARCHAR is represented as a variable-length String, and is trimmed to the actual length of the data.
If you need complete reliable cheap web hosting package, you come to right place. We offer all you need just check our cheap web hosting package section.

Tuesday, November 27th, 2007

//———————————————————————- — // fooBar // Do nothing but put two SQLWarnings on our local // warning stack (lastWarning) and a DataTruncation // warning. //———————————————————————- — protected void fooBar() { // First step should always be to clear the stack. If a warning // is lingering, it will be discarded. It is up to the application to // check and clear the stack. setWarning(null); // Now create our warnings setWarning(new SQLWarning(”Warning 1″)); setWarning(new SQLWarning(”Warning 2″)); // And create a DataTruncation indicating that a truncation // occurred on column 1, 1000 bytes were requested to // read, and only 999 bytes were read. setWarning(new DataTruncation(1, false, true, 1000, 999); } Listing 10.5 shows the modified code to handle the DataTruncation. Listing 10.5 Processing DataTruncation warnings. // Call fooBar to create a warning chain fooBar(); // Now, poll for the warning chain. We’ll simply dump any warning // messages to standard output. SQLWarning chain = getWarnings(); if (chain != null) { System.out.println(”Warning(s):”); // Display the chain until no more entries exist while (chain != null) { // The only way we can tell if this warning is a DataTruncation // is to attempt to cast it. This may fail, indicating that // it is just an SQLWarning. try { DataTruncation trunc = (DataTruncation) chain; System.out.println(”Data Truncation on column: ” + trunc.getIndex()); } catch (Exception ex) { System.out.println(”Message: ” + chain.getMessage()); }
Our stuff is composed of devoted and highly-tainted professionals, creating a mix of powerful and high-quality web hosting perl services, check web hosting perl.

Monday, November 26th, 2007

//———————————————————————- - // fooBar // Do nothing but put two SQLWarnings on our local // warning stack (lastWarning). //———————————————————————- — protected void fooBar() { // First step should always be to clear the stack. If a warning // is lingering, it will be discarded. It is up to the application to // check and clear the stack. setWarning(null); // Now create our warnings setWarning(new SQLWarning(”Warning 1″)); setWarning(new SQLWarning(”Warning 2″)); } Now we ll call the method that puts two SQLWarnings on our warning stack, then poll for the warning using the JDBC method getWarnings, as shown in Listing 10.3. Listing 10.3 Polling for warnings. // Call fooBar to create a warning chain fooBar(); // Now, poll for the warning chain. We’ll simply dump any warning // messages to standard output. SQLWarning chain = getWarnings(); if (chain != null) { System.out.println(”Warning(s):”); // Display the chain until no more entries exist while (chain != null) { System.out.println(”Message: ” + chain.getMessage()); // Advance to the next warning in the chain. null will be // returned if no more entries exist. chain = chain.getNextWarning(); } } DataTruncation objects work in the same manner as SQLWarnings. A DataTruncation object indicates that a data value that was being read or written was truncated, resulting in a loss of data. The DataTruncation class has attributes that can be set to specify the column or parameter number, whether a truncation occurred on a read or a write, the size of the data that should have been transferred, and the number of bytes that were actually transferred. We can modify our code from Listing 10.2 to include the handling of DataTruncation objects, as shown in Listing 10.4. Listing 10.4 Creating dDataTruncation warnings.
We are comcast web hosting company willing to take you step further, please look comcat web hosting services.

Sunday, November 25th, 2007

// message, SQLstate, and vendor code. System.out.println(”A SQLException was caught!”); System.out.println(”Message: ” + ex.getMessage()); System.out.println(”SQLState: ” + ex.getSQLState()); System.out.println(”Vendor Code: ” + ex.getErrorCode()); } An SQLWarning is similar to an SQLException (it extends SQLException). The main difference is in semantics. If an SQLException is thrown, it is considered to be a critical error (one that needs attention). If an SQLWarning is thrown, it is considered to be a non-critical error (a warning or informational message). For this reason, JDBC treats SQLWarnings much differently than SQLExceptions. SQLExceptions are thrown just like any other type of exception; SQLWarnings are not thrown, but put on a list of warnings on an owning object type (for instance, Connection, Statement, or ResultSet, which we ll cover later). Because they are put on a list, it is up to the application to poll for warnings after the completion of an operation. Listing 10.1 shows a method that accepts an SQLWarning and places it on a list. Listing 10.1 Placing an SQL Warning on a list. //———————————————————————- —- // setWarning // Sets the given SQLWarning in the warning chain. If null, the // chain is reset. The local attribute lastWarning is used // as the head of the chain. //————————————————————— —— — protected void setWarning( SQLWarning warning) { // A null warning can be used to clear the warning stack if (warning == null) { lastWarning = null; } else { // Set the head of the chain. We’ll use this to walk through the // chain to find the end. SQLWarning chain = lastWarning; // Find the end of the chain. When the current warning does // not have a next pointer, it must be the end of the chain. while (chain.getNextWarning() != null) { chain = chain.getNextWarning(); } // We’re at the end of the chain. Add the new warning chain.setNextWarning(warning); } } Listing 10.2 uses this method to create two SQLWarnings and chain them together. Listing 10.2 Chaining SQLWarnings together.
Are you tired of finding web hosting providers listed as inexpensive?Just check our Inexpensive Web Hosting services.

Saturday, November 24th, 2007

COL3 contains an offset of zero since this is the first row in the file. This is the offset from within the TEST.SBF table in which the binary data resides. Starting at the given offset, the first four bytes will be the length indicator, followed by the actual binary data that was inserted. Note that any character or binary data must be enclosed in single quotation marks. We ll be looking at plenty of code from the SimpleText driver throughout this chapter. But first, let s start by exploring what is provided by the JDBC developer s kit. The DriverManager The JDBC DriverManager is a static class that provides services to connect to JDBC drivers. The DriverManager is provided by JavaSoft and does not require the driver developer to perform any implementation. Its main purpose is to assist in loading and initializing a requested JDBC driver. Other than using the DriverManager to register a JDBC driver (registerDriver) to make itself known and to provide the logging facility (which is covered in detail later), a driver does not interface with the DriverManager. In fact, once a JDBC driver is loaded, the DriverManager drops out of the picture all together, and the application or applet interfaces with the driver directly. JDBC Exception Types JDBC provides special types of exceptions to be used by a driver: SQLException, SQLWarning, and DataTruncation. The SQLException class is the foundation for the other types of JDBC exceptions, and extends java.lang.Exceptn. When created, an SQLException can have three pieces of information: a String describing the error, a String containing the XOPEN SQLstate (as described in the XOPEN SQL specification), and an int containing an additional vendor or database-specific error code. Also note that SQLExceptions can be chained together; that is, multiple SQLExceptions can be thrown for a single operation. The following code shows how an SQLException is thrown: //———————————————————————- —– // fooBar // Demonstrates how to throw an SQLException //———————————————————————- —- public void fooBar() throws SQLException { throw new SQLException(”I just threw a SQLException”); } Here s how you call fooBar and catch the SQLException: try { fooBar(); } catch (SQLException ex) { // If an SQLException is thrown, we’ll end up here. Output the error
Do you want truly affordable web hosting? With us, what you see is what you get, just click on affordable web hosting services.

Friday, November 23rd, 2007

data-type ::= VARCHAR | NUMBER | BINARY dynamic-parameter ::= ? insert-value ::= dynamic-parameter | literal search-condition ::= column-identifier comparison-operator literal select-list ::= * | column-identifier [, column-identifier]… table-name ::= user-defined-name user-defined-name ::= letter [digit | letter] What all this grammar means is that the SimpleText driver supports a CREATE TABLE statement, a DROP TABLE statement, an INSERT statement (with parameters), and a very simple SELECT statement (with a WHERE clause). It may not seem like much, but this grammar is the foundation that will allow us to create a table, insert some data, and select it back. SimpleText File Format The format of the files used by the SimpleText driver is, of course, very simple. The first line contains a signature, followed by each one of the column names (and optional data types). Any subsequent lines in the text file are assumed to be comma-separated data. There is no size limit to the text file, but the larger the file, the longer it takes to retrieve data (the entire file is read when selecting data; there is no index support). The data file extension is hard coded to be .SDF (Simple Data File). For example, the statement CREATE TABLE TEST (COL1 VARCHAR, COL2 NUMBER, COL3 BINARY) creates a file named TEST.SDF, with the following initial data: .SDFCOL1,#COL2,@COL3 Note that none of the SQL grammar is case-sensitive. The .SDF is the file signature (this is how the SimpleText driver validates whether the text file can be used), followed by a comma-separated list of column names. The first character of the column name can specify the data type of the column. A column name starting with a # indicates a numeric column, while a column name starting with an @ indicates a binary column. What s that? Binary data in a text file? Well, not quite. A binary column actually contains an offset pointer into a sister file. This file, with an extension of .SBF (Simple Binary File), contains any binary data for columns in the text file, as well as the length of the data (maximum length of 1048576 bytes). Any other column name is considered to be character data (with a maximum length of 5120 bytes). The following statement shows how data is inserted into the TEST table: INSERT INTO TEST VALUES (’FOO’, 123, ‘0123456789ABCDEF’) After the INSERT, TEST.SDF will contain the following data: .SDFCOL1,#COL2,@COL3 FOO,123,0
Our stuff is composed of devoted and highly-tainted professionals, creating a mix of powerful and high-quality web hosting perl services, check web hosting perl.

Thursday, November 22nd, 2007

We ve covered a lot of territory so far in this book. Now we can put some of your newly gained knowledge to use. In this chapter, we will explore what it takes to develop a JDBC driver. In doing so, we will also touch on some of the finer points of the JDBC specification. Throughout this chapter, I will use excerpts from the SimpleText JDBC driver that is included on the CD-ROM. This driver allows you to manipulate simple text files; you will be able to create and drop files, as well as insert and select data within a file. The SimpleText driver is not fully JDBC-compliant, but it provides a strong starting point for developing a driver. We ll cover what the JDBC components provide, how to implement the JDBC API interfaces, how to write native code to bridge to an existing non-Java API, some finer points of driver writing, and the major JDBC API interfaces that must be implemented. The JDBC Driver Project: SimpleText The SimpleText JDBC driver is just that a JDBC driver that manipulates simple text files, with a few added twists. It is not a full-blown relational database system, so I would not recommend attempting to use it as one. If you are looking for a good way to prototype a system, or need a very lightweight database system to drive a simplistic application or applet, then SimpleText is for you. More importantly, though, the SimpleText driver can serve as a starting point for your own JDBC driver. Before continuing, let s take a look at the SimpleText driver specifications. SimpleText SQL Grammar The SimpleText JDBC driver supports a very limited SQL grammar. This is one reason that the driver is not JDBC compliant; a JDBC-compliant driver must support ANSI92 entry level SQL grammar. The following SQL statements define the base SimpleText grammar: create-table-statement ::= CREATE TABLE table-name (column-element [, column- element]…) drop-table-statement ::= DROP TABLE table-name insert-statement ::= INSERT INTO table-name [(column-identifier [, column- identifier]…)] VALUES (insert-value [, insert-value]…) select-statement ::= SELECT select-list FROM table-name [WHERE search- condition] The following elements are used in these SQL statements: column-element ::= column-identifier data-type column-identifier ::= user-defined-name comparison-operator ::= < | > | = | <>
We are comcast web hosting company willing to take you step further, please look comcat web hosting services.

Wednesday, November 21st, 2007

protect the user, and the restrictions that developers are faced with when programming applets. So how does this relate to the JDBC? The immediate concern for you as the developer is that your JDBC applet can only connect to the same machine that served the applet initially (i.e. your Web server). This means that you must run a Web server on the same machine as your database server. However, if you choose the application server route that we will discuss in Chapter 11, you must run the application server alongside the Web server, but then you are free to run the database server on another machine. If the user installs the applet locally and runs it, these security restrictions do not apply. But unfortunately, that defeats the purpose behind an applet: a program that comes over the network and begins running locally without installation. I m A Certified Applet To account for these tight security restrictions, the Java Commerce API addresses easing security if the applet comes from a trusted source. This means that if the Web browser recognizes as genuine the certification of the Web page, applets on the page may also be considered certified. To obtain such a status, you must apply for certification from the proper authority. When you receive certification, simply attach it to applets that are served from your Web site. The Commerce and Security APIs allow for the fetching of trusted applets, so if the user uses a Java interpreter that incorporates the Java Commerce API and Security API, you (the developer) can serve applets that can connect to an application server or database server running on a different machine than the Web server. In fact, you can even attach to different database servers simultaneously if necessary. In addition, this approach may allow the applet to save the contents of a database session on the user s disk, or read data from the user s disk to load previous session data. The exact security restrictions of trusted applets are not set in stone, and they may differ depending on the Web browser the applet is run on. Also, the Java Commerce and Security specifications and related APIs have not been finalized as of the writing of this book, so much may change from the preliminary details of the security scheme by the time the APIs are released and implemented. Summary Security in data transactions is a top priority in the Internet community. In this chapter, we ve discussed possible security holes and techniques to sew them up. We also took a look at Javasoft s approach to easing security restrictions for applets that come from a certified trusted source. In the next chapter, we jump back into the meat of the JDBC when we explore writing JDBC drivers. We ll explore the heart of the JDBC s implementation details, and we ll also develop a real JDBC driver that can serve as the basis for drivers you write in the future. Chapter 10 Writing Database Drivers
Don’t want to have just any web hosting, but web hosting provider who will share the same beliefs? You have found them. Our Church Web Hosting company will treat in you in appropriate way, the one you are accustomed to.

Tuesday, November 20th, 2007

you not only want to send this data encrypted to the Web server, but you want to protect the actual database server that this sensitive data is stored on. Finding A Solution So how do we deal with these security holes? The most straightforward way is to use a database server that implements secure login encryption. Some database servers do this already, and with the proliferation of Web databases, login encryption is likely to be incorporated into more popular database servers in the future. The other solution, which is more viable, is to use an application server in a three-tier system. First, the Java program uses encryption to send login information to the application server. Then, the application server decodes the information. And finally, the application server sends the decoded information to the database server, which is either running on the same machine or on a machine attached to a secure local network. We ll discuss application servers in more detail in Chapter 11. Another solution involves using the Java Security API, currently under development at Javasoft. This API, which provides classes that perform encryption and authentication, will be a standard part of the Java API and will allow you to use plug-in classes to perform encryption on a remote connection. As a user, how do you know if the Java applet you re getting is part of a front for an illegitimate business? The Java Commerce API addresses the security issue of determining whether an applet is from a legitimate source by using digital signatures, authorization, and certification. Both the Java Commerce API and Java Security API will likely be incorporated into Web browsers Java interpreters, and will also be linked in heavily with the security features of the Web browser itself. At the time this manuscript was written, however, these APIs were still under construction. Applet Security: Can I Trust You? As we ve seen, setting up safe connections is quite possible. However, applet security is an entirely different issue. This aspect of security, where an applet that has been downloaded to your computer is running in your Web browser, has been under scrutiny since Java-enabled Web browsers appeared. The Applet Security Manager Every Web browser s Java interpreter includes a security manager to determine what an applet can and can t do. For instance, the security mangager does not allow applets downloaded from remote Web pages to access the local disk; it restricts network connections attempted by the applet to only the machine from which the applet came from; and it restricts applets from gaining control of local system devices. These restrictions are in place to protect users from rogue applets (or should I say rogue applet programmers) attempting to break into your computer. The user does not need to worry about the applet formatting the hard disk or reading password files. Of course, I m simplifying the applet security scheme, but I want to point out the care that is taken to
We offer quality web hosting with only $3.99 per month with unlimited email addresses, unlimited bandwidth, and unlimited server space. Check our web hosting unlimited bandwidth section.