Acknowledgments p. xi About the Authors p. xiii Introduction p. xv An Overview of MySQL p. 1 Why Use an RDBMS? p. 2 Multiuser Access p. 2 Storage Transparency p. 2 Transactions p. 3 Searching, Modifying, and Analyzing Data p. 4 Ad Hoc Queries p. 5 Why Choose MySQL? p. 5 MySQL and JDBC p. 7 What's Next p. 8 JDBC and Connector/J p. 9 What Is JDBC? p. 9 What about ODBC? p. 10 Modeling Database Applications with JDBC p. 11 JDBC Versions p. 13 JDBC Driver Types p. 13 SQL Standards p. 14 Examining the JDBC Interface p. 15 The java.sql Package p. 15 The javax.sql Package p. 18 Understanding Connector/J p. 21 JDBC Support within 3.0.1 p. 22 Obtaining JDBC Drivers p. 24 What's Next p. 24 Working with MySQL SQL p. 25 What Is a Database? p. 25 Database Models p. 27 Data Types p. 29 Designing a Database p. 29 Introducing MySQL SQL p. 32 Overview of MySQL p. 33 Creating Databases p. 34 Creating Tables p. 35 Inserts p. 39 Selects p. 40 SELECT Statement Extensions p. 42 Updates p. 47 Deletes p. 50
Using SHOW p. 51 More on Tables p. 53 Transactions p. 55 Functions/Operators p. 56 Joins p. 56 NULL p. 59 What's Next p. 59 Installing MySQL, Java, and Connector/J p. 61 Installing MySQL p. 61 Linux Installation p. 62 Windows Installation p. 63 All Other Installations p. 63 Installing Java p. 64 Testing the Java Installation p. 64 Installing Connector/J p. 65 Testing the Connector/J Installation p. 66 What's Next p. 66 Using JDBC with Java Applications and Applets p. 67 Hello World p. 67 Loading the Connector/J Driver p. 69 Using DriverManager to Connect to a Database p. 69 Executing Queries Through Statement Objects p. 75 Using the ResultSet Object p. 78 Determining the Cursor Position p. 79 Moving the Cursor p. 79 Getter Methods p. 80 Primitive Getters p. 82 Closing the Objects p. 85 Making It Real p. 85 Our Main Function p. 88 The init() Method p. 89 The buildgui() Method p. 89 Executing a Query with No Results p. 91 Deleting Database Rows p. 97 Updating Database Rows p. 99 Create Table p. 101 Drop Table p. 101 Disconnecting from the Database p. 103 Advanced ResultSet Manipulation p. 104 One Step Forward p. 113 One Step Back p. 114
Fast-Forward to the End p. 114 Rewind to the Beginning p. 114 Goto Record p. 114 Freehand Query p. 115 Batches p. 115 Limiting Results p. 116 Database Warnings and Exceptions p. 117 What's Next p. 118 Achieving Advanced Connector/J Functionality with Servlets p. 119 Servlets p. 119 DataSource Connections p. 122 Execution Environment p. 123 Databases p. 123 PreparedStatements p. 124 Connecting to the Database p. 129 Determining the Submit Type p. 129 Displaying Data p. 130 Updating Data p. 132 Using Placeholders in a Loop p. 133 Using Placeholders in PreparedStatement p. 134 Using setobject/setbytes p. 136 Getting BLOBs p. 139 Joins p. 141 Updatable ResultSets p. 142 The Update Button Code p. 149 The Insert Button Code p. 150 Update Methods p. 152 Manipulating Date/Time Types p. 154 Methods for Retrieving a Value as a Date Type p. 155 Methods for Retrieving a Value as a Time Type p. 155 Methods for Retrieving a Value as a Timestamp Type p. 155 Handling BLOB and CLOB p. 156 Using Streams to Pull Data p. 158 Handling ENUM p. 159 Using Connector/J with JavaScript p. 161 What's Next p. 163 MySQL Type Mapping p. 165 Character Column Types p. 166 Char p. 166 Varchar p. 167 Tinytext p. 167
Text p. 167 Mediumtext p. 167 Longtext p. 168 Tinyblob p. 168 Blob p. 168 Mediumblob p. 168 Longblob p. 169 Set p. 169 Enum p. 169 Using Character Types p. 169 Date and Time Column Types p. 171 Date p. 172 Time p. 172 Datetime p. 172 Year p. 173 Timestamp p. 173 Using Date and Time Types p. 173 Numeric Column Types p. 175 Tinyint p. 176 Smallint p. 176 Mediumint p. 176 Int p. 177 Bigint p. 177 Float p. 177 Double p. 177 Decimal p. 178 Using Numeric Types p. 178 What's Next p. 180 Transactions and Table Locking with Connector/J p. 181 Understanding the Problem p. 181 MySQL's Transaction Table Types p. 182 The InnoDB Table Type p. 182 The BDB Table Type p. 184 Converting to Transactional from Nontransactional p. 184 Performing Transactions in MySQL p. 185 Using the autocommit Variable p. 185 Update Transactions p. 187 The SELECT/INSERT Transaction p. 190 Multiple Table Transactions p. 191 Foreign Key Integrity on Deletes p. 192 Ending a Transaction p. 192
Transaction Isolation p. 192 Dirty Reads p. 193 Phantom Reads p. 194 Nonrepeatable Reads p. 194 Table Locking p. 195 What's Next p. 196 Using Metadata p. 197 Using Database Metadata p. 197 Getting the Object p. 200 General Source Information p. 202 Feature Support p. 203 Data Source Limits p. 204 SQL Object Available p. 204 Transaction Support p. 204 The ResultSet Metadata p. 205 Getting Column Information p. 205 Other ResultSet Metadata p. 208 What's Next p. 210 Connection Pooling with Connector/J p. 211 What Is a Connection Pool? p. 212 Pooling with DataSource p. 213 Pooling with the DriverManager p. 218 DDConnectionBroker p. 219 What's Next p. 221 EJBs with MySQL p. 223 Multi-tier Architecture p. 223 Using Beans p. 225 EJB Types p. 225 The EJB Environment p. 226 Application Server Configuration p. 229 The Role of the Servlet p. 230 Entity Beans p. 230 Session Beans p. 234 Using the Beans p. 236 Adding a Query p. 238 Bean-Managed Persistence p. 240 ejbcreate() p. 241 ejbload() p. 242 ejbstore() p. 243 ejbremove() p. 243 ejbfindbyprimarykey() p. 244
Setter/Getter Methods p. 245 What's Next p. 245 Building a General Interface for MySQL p. 247 Tasks p. 248 SQL Exceptions p. 252 MySQL Connections p. 253 The Task Delegate p. 255 The Task Manager p. 255 Task Results p. 264 The Database Information Task p. 268 User Input for Tasks p. 270 The SQL Query Task p. 272 The Show Columns Task p. 275 The Insert Row Task p. 280 What's Next p. 286 Database Administration p. 287 Using the mysql Administration Application p. 287 Managing Users and Permissions p. 289 Changing Root p. 289 Adding Users p. 290 Limiting Resources p. 292 Configuring the Query Cache p. 293 Forcing a Cache p. 294 Understanding Log Files p. 294 Error Logs p. 295 General Logs p. 295 Binary Logs p. 296 Slow Query Logs p. 296 Maintaining Your Tables p. 296 Repairing Tables p. 297 Backing Up and Restoring Your Database p. 298 Restoring Data p. 301 InnoDB Table Types p. 302 DBD Table Types p. 302 What's Next p. 303 Performance and Tuning p. 305 Connector/J 3.0 Performance p. 305 Database Tuning p. 308 Server Options p. 308 Using RAID p. 309 Optimizing Tables p. 309
The MySQL Query Optimizer p. 310 Table Indexes p. 312 JDBC Tuning p. 313 Minimizing Data Requests p. 313 Keeping Consistent Connections p. 314 Handling Statements p. 315 Batching p. 316 Using Transactions and Locking p. 316 Defining the Architecture p. 317 Getting Data p. 317 Conclusion p. 318 MySQL Development and Test Environments p. 319 Test Architecture #1 p. 319 Test Architecture #2 p. 320 Servlet Architecture p. 321 The EJB Architecture p. 323 Databases and Tables p. 325 The accounts Database and Tables p. 325 The identification Database and Tables p. 326 Test Databases p. 327 Database Products p. 327 The Database Test p. 327 The JDBC API and Connector/J p. 329 The java.sql Package p. 330 Array p. 331 BatchUpdateException p. 332 Blob p. 332 CallableStatement p. 333 Clob p. 335 Connection p. 335 DataTruncation p. 337 DatabaseMetaData p. 337 Date p. 343 Driver p. 343 DriverManager p. 343 DriverPropertyInfo p. 344 ParameterMetaData p. 344 PreparedStatement p. 345 Ref p. 346 ResultSet p. 347 ResultSetMetaData p. 350
Savepoint p. 351 SQLData p. 351 SQLException p. 352 SQLInput p. 352 SQLOutput p. 353 SQLPermission p. 353 SQLWarning p. 354 Statement p. 354 Struct p. 355 Time p. 356 Timestamp p. 356 Types p. 357 The javax.sql Package p. 358 ConnectionEvent p. 359 ConnectionEventListener p. 359 ConnectionPoolDataSource p. 359 DataSource p. 360 PooledConnection p. 360 RowSet p. 360 RowSetEvent p. 362 RowSetInternal p. 362 RowSetListener p. 363 RowSetMetaData p. 363 RowSetReader p. 363 RowSetWriter p. 364 XAConnection p. 364 XADataSource p. 364 MySQL Functions and Operators p. 367 Arithmetic Functions/Operators p. 369 Comparison Functions/Operators p. 372 Logical Operators p. 375 Control Functions p. 377 String Functions/Operators p. 379 Grouping Functions p. 384 Date and Time Functions p. 386 Other Functions p. 394 Connector/J Late-Breaking Additions p. 397 Failover Support p. 397 Windows Named Pipes p. 398 Batch Processing Error Continuation p. 398 Strict Updates p. 399
Profile SQL p. 399 SSL p. 399 Index p. 401 Table of Contents provided by Blackwell's Book Services and R.R. Bowker. Used with permission.